If I modify 10 files (uncommitted) and I want to commit those 10 files (modified), is a commit message given for each file or one message for all files?
CodePudding user response:
Git does not think in terms of files; it thinks in terms of snapshots of the entire repository. When you create a commit, you are creating a new snapshot of the repository, based on the files which you "stage" with git add
(or in other ways).
It's worth mentioning here that git doesn't think in terms of changes either, so every file in your repository is part of that commit, even the ones you didn't change. However, commands like git log
are smart enough to know what you mean by "the history of this file", and skips over the commits where that file is identical to the previous commit.
In short: the commit message applies to the whole commit, which applies to the whole repository.
CodePudding user response:
A commit is a logical entity that describes a change you want to make. Assuming the changes in all these files are part of the same logical change, they should all be included in a single commit.
CodePudding user response:
If you worked on a same task in all these files then you can add them simply by git add . and then give your message by git commit -m "you message". if you have done multiple tasks then add you desired files by giving their path in command git add "path to file" and then add message for given file git commit -m "your message".
CodePudding user response:
One message for all assuming you have git add
those 10 files from working directory to the staging area.