Time to read: 1 minutes.
The project I am currently leading is following A Successful git Branching Model with only a few modifications.
Create a Bug Fix / New Feature Branch
When a developer goes to work on a new task, bug or feature they should make new branch from the
develop branch to start their work. The new branch will be named after the Jira task ID, which in the following example is
$ git checkout develop // make develop branch current $ git pull // get latest commits $ git checkout -b EDOC-1234 develop // make new EDOC-1234 branch
That creates a new branch for you in your local repository named
EDOC-1234 based on the
develop branch where everyone’s latest work is checked in. From there you can work on your new feature. For example:
$ echo "42">>theAnswer.txt $ add theAnswer.txt $ commit -m "The answer to life, the universe and everything" $ echo "43">>yetMore.txt $ add yetMore.txt $ commit -m "A present for the god who has everything: one more thing beyond 42"
Update your Bug Fix / Feature Branch with the Latest From the
If someone commits to the
develop branch while you are working on your feature you can get their work by (re)merging the
develop branch to your
$ git checkout develop // switch to the develop branch $ git pull origin develop // pull the latest changes from the develop branch at origin $ git checkout EDOC-1234 // switch back to your feature branch $ git merge develop // add all the changes from the develop branch to your feature branch
Merge your Bug Fix / Feature Branch Back to the
When you are done with your feature, merge it back to the
$ git checkout develop // switch the the develop branch $ git pull origin develop // pull the latest commits to the develop branch on origin $ git merge --no-ff EDOC-1234 // merge the updates from the develop branch on origin $ git push origin develop // push your merged work to origin
Deleting a Bug Fix / Feature Branch
This will be done after the branch has had a code review and Q/A is complete.
$ git branch -d EDOC-1234 // remove your feature branch