When you do a rebase, it saves all commits in the current branch that are not available in the upstream branch to a staging area, and reset the current branch to upstream branch. Then those saved commits would be reapplied on top of the current branch, one by one. With this process, it ensures my newest changes would remain as the newest.
The new workflow with rebasing would be:
1 git pull origin master 2 git checkout -b new-feature-branch 3 git status 4 git commit -am "commit message" 5 <--cycle from step 2-4, until work is done--> 6 7 git checkout master 8 git pull origin master #update the master before merging the new changes 9 git checkout new-feature-branch 10 git rebase master #apply the new changes on top of current master 11 12 git checkout master 13 git merge new-feature-branch 14 git push originThough it seems to be longer than the previous workflow, it helps me to stay away from unnecessary conflicts. Even if they do occur, resolution of them are pretty straight-forward, as I know for sure what is the newest change.
Lakshan Perera provides great examples of Git at work -- including this gem on when to use git rebase.
Check out the original post for git cherry-pick, bisect and more.
Comments (0)
Leave a comment...