- Published on
My Git Workflow
- Authors
 - Name
- Kevin Old
- @kevinold
 
 
TLDR;
- Keep mastershippable
- Develop on a branch
- Rebase only on a branch other than master
- Merge development branch back to master
- Use git fetchandgit merge origin masterovergit pull
- Do a dry run before pushing to master: git push --dry-run origin master
Details
Develop on a branch
- On master: git co -b new_branch
- (will be switched to new_branch)
- Develop, commit, rebase as needed
Staying up to date
As new changes are committed to master, get them from the server and bring those into the branch before merging back into master.
- Switch to master git co master(note, the next 3 steps (with the exception of the 2nd) are the same as "git pull")
- git fetch
- review newly downloaded changes git log origin/master
- merge into master git merge origin/master
Getting changes onto the branch
To get the new change into new_branch:
- Switch to new_branch git co new_branch
- git rebase master
A breakdown of what rebase does:
- The commits I've made to new_branchare "lifted" or "stashed" off of the branch
- A git merge masteris performed
- My "lifted" commits are then reapplied
Note: If there are conflicts, I am prompted to fix them at this point, on the branch
Work is complete
When I am ready to merge all work done on new_branch back into master I simply do:
- From new_branch: git co master
- On master: git merge new_branch
Measure twice, cut once
At this point, before pushing code to origin, I do a "dry run" to verify I have the latest changes from master after my last fetch
git push --dry-run origin master
Then if all is clean:
git push origin master