Skip to content

Instantly share code, notes, and snippets.

@abel-masila
Last active April 6, 2020 17:47
Show Gist options
  • Save abel-masila/1cb9e006e3d954c505fae6136ae8eb87 to your computer and use it in GitHub Desktop.
Save abel-masila/1cb9e006e3d954c505fae6136ae8eb87 to your computer and use it in GitHub Desktop.

Yoda Gitflow Workflow.

Develop and Master Branches

Instead of a single master branch, this workflow uses two branches to record the history of the project. The master branch stores the official release history, and the develop branch serves as an integration branch for features.

We already have a master branch for both projects. To create a develop branch, which will only be done once by one of the team members, run:

git checkout -b develop
or
git  branch develop

Then push to github:

git  push -u origin develop

Feature Branches

Each new feature should reside in its own branch, which can be pushed to the central repository for backup/collaboration. But, instead of branching off of master, feature branches use develop as their parent branch. When a feature is complete, it gets merged back into develop. Features should never interact directly with master.

Creating a feature branch

git checkout develop
git checkout -b feature/name

After creating the feature branch off develop, you work on that feature to completion and below is the flow you use to push your changes to github.

git add .
git commit -m "commit message here.."
git pull --rebase origin develop
git push origin feature/name

Notice the rebase stage, this stage is usually important to get existing code changes which have already been merged into develop by team members. Here you might run into rebase conflicts if any of the team members worked on same files you have been working on.

Incase of rebase conflicts, kindly review the current change in develop branch and also your incoming code change and accept the correct code changes in that file. After this, follow the next steps to resolve the conflict and push your code changes to github:

git add .
git rebase --continue
git push origin feature/name

After this, just go to github and open a pull request to develop branch, request for reviews from team members and once cleared, your feature will be merged to develop. Then the changes will merged to master by the manager or any other person with the permissions to do this.

Hotfix Branches

Maintenance or “hotfix” branches are used to quickly patch production releases. hottfix branches are a lot like feature branches except they're based on master instead of develop. This is the only branch that should fork directly off of master. As soon as the fix is complete, it should be merged into both master and develop.

git checkout master  
git checkout -b hotfix/branchname

Similar to finishing a release branch, a hotfix branch gets merged into both master and develop.

git add .
git commit -m"hotfix summary"
git pull --rebase origin master
git push origin hotfix/branchname

Then open a pull request from your hotfix branch to master and develop.

The overall flow of Gitflow is:

  1. A develop branch is created from master
  2. Feature branches are created from develop
  3. When a feature is complete it is merged into the develop branch
  4. If an issue in master is detected a hotfix branch is created from master
  5. Once the hotfix is complete it is merged to both develop and master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment