git commit frequency

前端 未结 11 1758
后悔当初
后悔当初 2020-11-29 21:06

Since i switched to git from svn i started make more commits every time i recompile and my tests pass i commit my work. In the end i end up committing function by function.<

11条回答
  •  遥遥无期
    2020-11-29 21:42

    In the end i end up committing function by function

    Do not forget you could rather "git add" function by function, making only one commit:

    • once all the functions are written or fixed for a given task
    • or once you realize the current function is too large/complicated to be part of a commit any time soon: you can then commit what is currently "on stage" ("git added"), which would not include your current modifications in the working directory.

    Then, the number of commits can be related to the purpose of the branch:

    • local branch: go crazy, commit anytime you want
    • "public" branch (one that you will push):
      • for a local repository (for selected group of people): you could regroup at least the very small "intermediate" commits
      • for a public repository (for all developers, or other projects to see): you can make an interactive rebase in order to regroup your commit by "activity" or "task" in order to make those more readable.

    In short, "publication considerations" can, in a DVCS (as in "Distributed"), guide you as to make the proper number of commits for the right reasons.

提交回复
热议问题