Search code examples
gitcommit-message

Git commit messages if I split a single task into 2 commits


For example, if I haven’t finished a task at the end of a day but want to commit and push my work. The next day I’ll finish the task and commit the finished task again. What should the 2 commit messages look like?

For example Apply new Changes (Part1) and Apply new Changes (Part2) looks not like a good commit message to me.


Solution

  • Better not push such commits to the target branch. You could commit as often as possible with whatever commit messages you like. Consider them as drafts. You will have little chance to lose your changes. Every commit stays long enough. You could push them to a backup branch or a backup repository in another host if you don't think the local repository is safe enough. When you finish one task, squash all the related draft commits into one, with git reset --soft && git commit, git rebase -i, or git merge --squash. Write the message carefully to include helpful and well-formatted infomation for this formal commit.