GithubHelp home page GithubHelp logo

git-flow-overview's Introduction

1. Git Flow Overview:

The Git flow workflow defines a strict branching model designed around the project release. The main components are:

  • Main (or Master): This branch contains production-ready code.
  • Develop: This branch contains features that are ready for the next release.
  • Feature branches: Branches created for new features or issues.
  • Release branches: Branches that prepare the next production release.
  • Hotfix branches: Branches that quickly patch production releases.

2. Initial Setup:

Ensure you have the latest version of your repo:

git clone https://github.com/juanjaragavi/juan-jaramillo-api-endpoints.git
cd juan-jaramillo-api-endpoints

GitHub Desktop:

  1. Open GitHub Desktop.
  2. Click on File > Clone Repository.
  3. Choose the URL tab and enter the repository's URL, then click Clone.

3. Development Workflow:

Starting a new feature:

git checkout develop
git pull origin develop
git checkout -b feature/your-feature-name

GitHub Desktop:

  1. Make sure you are on the develop branch.
  2. Fetch the latest changes.
  3. Click the Current Branch dropdown and choose New Branch, name it feature/your-feature-name.

Finishing a feature:

After finishing the development and testing of your feature:

git add .
git commit -m "Completed feature/your-feature-name"
git push origin feature/your-feature-name

GitHub Desktop:

  1. Make your changes and then click on Commit to feature/your-feature-name.
  2. Click the Publish Branch button to push your feature branch to the remote.

4. Preparing for a Release:

Creating a release branch:

git checkout develop
git pull origin develop
git checkout -b release/vX.Y.Z

GitHub Desktop:

  1. Make sure you're on the develop branch.
  2. Fetch the latest changes.
  3. Click the Current Branch dropdown and choose New Branch, name it release/vX.Y.Z.

Finishing a release:

After final testing:

git checkout main
git merge release/vX.Y.Z
git push origin main
git checkout develop
git merge release/vX.Y.Z
git push origin develop
git branch -d release/vX.Y.Z

GitHub Desktop:

  1. Change to the main branch.
  2. Choose Merge into Current Branch under the Branch menu and select your release branch.
  3. Push the changes to main.
  4. Repeat the merge process for the develop branch.
  5. Delete the release branch by right-clicking it in the Current Branch dropdown.

5. Hotfixes:

Hotfixes are branches that derive from main and are meant to fix critical issues.

Creating a hotfix branch:

git checkout main
git pull origin main
git checkout -b hotfix/your-hotfix-name

GitHub Desktop:

  1. Make sure you're on the main branch.
  2. Fetch the latest changes.
  3. Click the Current Branch dropdown and choose New Branch, name it hotfix/your-hotfix-name.

Finishing a hotfix:

After the hotfix is tested:

git checkout main
git merge hotfix/your-hotfix-name
git push origin main
git checkout develop
git merge hotfix/your-hotfix-name
git push origin develop
git branch -d hotfix/your-hotfix-name

GitHub Desktop:

  1. Change to the main branch.
  2. Choose Merge into Current Branch under the Branch menu and select your hotfix branch.
  3. Push the changes to main.
  4. Repeat the merge process for the develop branch.
  5. Delete the hotfix branch by right-clicking it in the Current Branch dropdown.

Note: Ensure you regularly merge develop into your feature branches to avoid large merge conflicts.

To revert all changes made in the develop branch and make it identical to the main branch using the Git flow strategy, you can follow these steps:

  1. Make sure you're in the develop branch:

    git checkout develop
  2. Fetch the latest changes: This ensures you have the latest state of both develop and main branches.

    git fetch
  3. Reset the develop branch to the main branch:

    git reset --hard origin/main

    This command will make the develop branch's pointer point to the same commit as main branch's pointer, effectively discarding all changes in develop since it diverged from main.

  4. Push the changes to the remote repository: Since you've rewritten the history of the develop branch, you'll need to forcefully push the changes to the remote repository.

    git push origin develop --force

    โš ๏ธ Be cautious when using --force as it can overwrite changes on the remote that you don't have locally. It's good practice to communicate with your team before performing such actions to ensure no work is lost.

Now, the develop branch will be in the exact same state as the main branch.

Remember to always backup or ensure you have other means to recover your work before performing destructive operations like these.

To switch to the main branch, you simply use the git checkout command. Here's how you can do it:

git checkout main

If you're using Git version 2.23 or later, you can also use the git switch command, which is more intuitive for this kind of task:

git switch main

After running either of these commands, you'll be on the main branch. You can confirm this by running:

git branch

The currently active branch will be indicated with an asterisk (*) next to its name.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.