0

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.

Melebius
  • 6,183
  • 4
  • 39
  • 52
Julian
  • 422
  • 2
  • 6
  • 10
  • 2
    Make them more descriptive. What changes? Your two messages explain nothing as to what the commit contains. – ggdx Nov 15 '17 at 10:08

2 Answers2

3

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.

ElpieKay
  • 27,194
  • 6
  • 32
  • 53
1

Unfinished work should not be pushed. A commit should be atomic1, containing one (and only one) complete task unless it can be split into reasonable subtasks.

If you want to push your unfinished work for the backup purpose, use a branch that is OK to rebase the next day when you amend your previous commit.


1 Atomic in the meaning of using VCS, there is another meaning describing how VCS shall work internally.

Melebius
  • 6,183
  • 4
  • 39
  • 52
  • 2
    I recommend committing unfinished features to a local branch based off your current branch. Actually, I have written a blog post about this problem, you can read it [here](https://labs.consol.de/git/development/2015/06/23/git-merge-squash.html). You might want to also push this branch as backup, but it is important for all team members to know that this is your personal branch and nobody bases new work off this temporary branch. – gucce Nov 15 '17 at 13:36