Git: Merging a Feature Branch
A common practice among Git users is to use feature branches for individual feature changes or enhancements while work is ongoing. After the feature is complete and tested, it is merged into master. The master branch usually represents all current features that are in a working and deployable state.
The following workflow demonstrates how to accomplish this task. Note that featurebranch below should be changed to something meaningful (i.e. update_to_rubyonrails4).
1 # optionally start work without a feature branch 2 # make the feature branch 3 git checkout -b featurebranch 4 # work on the feature branch 5 # add and commit changes 6 git add -p 7 git commit 8 # change to master 9 git checkout master 10 # merge feature branch into master without commit 11 git merge --no-commit featurebranch 12 # unstage changes in master 13 git reset HEAD 14 # make selective commits 15 git add -p 16 git commit 17 # remove the merged feature branch 18 git branch -d featurebranch # -D if merge was not complete but want the branch deleted