Git commit style: All changed files at once or one at a time?

前端 未结 2 1236
难免孤独
难免孤独 2020-12-05 11:56

I am saving my work at night with a single commit for many files. I wonder if it would be better to commit for each file but this seems like a lot more work.

I have

2条回答
  •  悲哀的现实
    2020-12-05 12:15

    "Easy to understand" means also:

    • commits representing not just "checkpoint" (like they would if you committed after each file modification), but a coherent state of the code
    • easy to git bisect (ie each commit should represent a change in a task, which compiles and add an evolution or a new feature, and not a "checkpoint commit", which would make the git bisect fails way too soon)

    See "understanding the Git workflow" for more: you need to differentiate:

    • private branches (that you never push), where you can commit basically at any time, and
    • public branches (that you will push on GitHub), which needs to be clean-up and have meaningful commits.

    So pay attention to the "fast-forward" merge that Git uses by default: don't forget to clean-up the history of branches you are about to merge that way into public branches.

提交回复
热议问题