Everyone knows Git makes it easy to switch from branch to branch. But how do you handle interruptions?
Use a Memo
Say James bugs you to look at his branch, but you don’t want to forget what you were about to do in your branch. How can you mark what you were about to do, but haven’t gotten to yet?
How about a “memo” commit?
git commit --allow-empty -m 'Resume fixing logic for user comparison'
This is cool. It’s like a sticky note waiting for you when you come back to your branch.
Once you finish doing your colleague’s work, your nice sticky note will be waiting for you.
~/Desktop/foo$ git log --oneline develop..HEAD 10a778f (HEAD -> add-user-form) Resume fixing logic for user comparison 97f4a16 Add header
Oh, yeah! I was fixing the user comparison.
What about the garbage?!
Are you worried about junking up your Git history? Good. I think we’d be friends. If you’re a polite developer, you’ll rebase your work before creating a pull request.
And guess what happens when you rebase…
git rebase -i develop
pick 97f4a16 Add header # pick 10a778f3745645ac7a8a086adcefe80d704b141c Resume fixing logic for user comparison pick 11eed75 Fix user comparision logic pick fbe0b5d Add footer
Git comments out empty commits. 😍 You don’t even have to worry about removing your memos.