问题
I am new to git having previously used Perforce, SVN, source safe and many other source control tools.
I am looking for the functionality that I used to use in Perforce where I could construct a change list; I was able to add files to the change list and provide a comment specific to each file.
git has a staging area into which changed files are added, is there a way to provide a per file comment when adding a file to the staging area?
Or perhaps at the comment stage I can add a per file comment; I have had a good look and not been able to workout if either how to perform either - in fact from what I can seen neither is possible.
Anyone have any ideas how I could do this?
回答1:
Git does not provide such feature. The Git philosophy is to track 'content', not 'files'. Adding files to the staging area allow you to prepare precisely your commit. If several files are added to the staging area, it's because there are linked to the same feature. That's why the commit message represents the whole change.
If you need a message per file, you may consider creating several commits on a feature branch, with only one file per commit.
Hope this helps.
回答2:
These days you CAN add commit messages to individual files. I just did this for instance:
git commit -m 'reference containers in app' src/App.js
Context: multiple files added to git through $git add .
THEN: commit message on this individual file (src/App.js).
[posting answer since this still comes up in google]
回答3:
You can just go to the folder after some change do:
git add .
git commit -m 'mssg'
and go back and push it:
git push origin master
回答4:
In each file in git you will see '+' when you do hover, click on that add your comments for each file.
来源:https://stackoverflow.com/questions/17073808/git-commit-comment-per-file