Friday, June 12, 2015

Git simple Feature Branch Workflow

In my previous post, I wrote about git work flows. Now I will going to try out simple 'Feature Branch Workflow'.
1. I pull down the latest changes from master
git checkout master
git pull origin master

2. I make branch to make changes 
git checkout -b new-feature

3. Now I am working on the feature

4. I keep my feature branch fresh and up to date with the latest changes in master, using 'rebase'
Every once in a while during the development update the feature branch with the latest changes in master.

git fetch origin
git rebase origin/master

In the case where other devs are also working on the same shared remote feature branch, also rebase changes coming from it:

git rebase origin/new-feature

Resolving conflicts during the rebase allows me to have always clean merges at the end of the feature development.

5. When I am ready I commit my changes
git add -p
git commit -m "my changes"

6. rebasing keeps my code working, merging easy, and history clean.
git fetch origin
git rebase origin/new-feature
git rebase origin/master

Below two points are optional
6.1 push my branch for discussion (pull-request)
git push origin new-feature

6.2 feel free to rebase within my feature branch, my team can handle it!
git rebase -i origin/master

Few point that can be happen in developing phase.
Another new feature is needed and it need some commits from my new branch 'new-feature' that new feature need new branch and few commits need to push to it and clean from my branch.

7.1 Creating x-new-feature branch on top of 'new-feature'
git checkout -b x-new-feature  new-feature

7.2 Cleaning commits
//revert a commit
git revert --no-commit
//reverting few steps a back from current HEAD
git reset --hard HEAD~2

7.3 Updating the git
//Clean new-feature branch
git push origin HEAD --force

No comments:

Post a Comment