git commit best practices

前端 未结 7 1617
半阙折子戏
半阙折子戏 2021-01-30 05:24

I am using git to manage a C++ project. When I am working on the projects, I find it hard to organize the changes into commits when changing things that are related to many plac

7条回答
  •  情书的邮戳
    2021-01-30 05:51

    This is exactly the use case, for which the index, the staging area, was introduced in git.

    You can feel free to do as many changes unrelated to each other as possible. Then you choose what all are related and then make several atomic commits in one shot.

    I do it all the time. If you use git-gui or any of the other GUI clients, you can choose not only the file that you want to commit, but also hunks within the files, so your commits are as atomic as possible.

提交回复
热议问题