3 ms·
Empty commits are important! They help when you want to write your thoughts down in a commit message before making the actual code change.
by rwmj 4y ago
Empty commits are important! They help when you want to write your thoughts down in a commit message before making the actual code change.
- u801e 4y agoI make empty commits when I want to update the commit message without changing anything in the referenced tree. I do this by prefixing the title of the commit I message I want to update with squash!. Then, when run an interactive rebase with the --keep-empty flag, git will open my editor and I can just delete the original commit message and leave the new commit message I made with the squash! prefixed commit and then continue with the rebase. This allows me to essentially show how I would change a commit message without having to run rebase or amend a commit in a code review, which hides the original commit.
- myme 4y agoAh, what a stellar use case. It's been forever since I looked into git notes (or was it annotations? can't check right now). But I guess those had significant flaws. Empty commits that you can use the message as a todo-list and fixup/amend in changes as you go. Might try this.
- ekimekim 4y agoI occasionally use empty commits to leave notes to myself that I want to be shown when I go to clean up my history (generally with rebase -i) and get it ready for review. It works well as rebase -i will default to commenting out empty commits, thus drawing attention to them.