My git workflow
In this post, I’m going to write down my git workflow so that the next time I find myself talking/thinking about it, I’ll be able to use my blog as a reminder and visual support.
I usually follow the feature branch workflow, creating a branch per feature:
git checkout -b new-feature master
Then, I work and commit code on my local branch as often as I need
git add -A
git commit
Sometimes, I also save my branch in the remote repository
git push -u origin new-feature
When I think the feature is ready to go, I review the commits, reorder and squash some of them.
Then I open a pull request. When I get comments on the code, I add temporary commits in response to them. If these commits are fixes to previous ones, I like to use fixup
git commit --fixup=SHA
Once the merging of the branch is approved, I rebase master and fixup the temporary commits into the original ones
git rebase master -i --autosquash
Finally, I merge the feature branch into master.
git checkout master
git merge new-feature master
git push origin master
Ah, I’ve forgotten something! I also follow some practices to elaborate my commit messages. Here you have a post I use to refresh my memory when I need to remember the best practices for commit messages.