Search code examples
gitversion-controlpycharmcommit

Is it good practice to commit multiple files at once?


I am a new user to PyCharm, and recently started using its VCS (Version Control System) tool. Whenever I want to commit the changes that I made to a project, VCS opens, by default, a window with all the changes that I made to all files within that project, and suggests me to commit all of those changes in a single commit. Is this a good practice?


Solution

  • A commit should be "atomic", that is it should contain a group of related changes that are meant to work together. How many files are concerned is irrelevant. What you shouldn't do is

    1. commit unrelated changes together (i.e. a group of changes implementing a new feature and a single change fixing a bug) - because then you apply the bugfix alone (chery-pick) to another branch,

    2. commit only part of related changes (i.e. you changed the prototype of a function in a given file but didn't fix all the calls to this functions) resulting in a broken code base.