每个文件的 git commit 注释
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17073808/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
git commit comment per file
提问by user2196409
I am new to git having previously used Perforce, SVN, source safe and many other source control tools.
我是 git 的新手,以前使用过 Perforce、SVN、源安全和许多其他源控制工具。
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.
我正在寻找我曾经在 Perforce 中使用的功能,我可以在其中构建更改列表;我能够将文件添加到更改列表并提供特定于每个文件的注释。
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?
git 有一个暂存区,将更改的文件添加到其中,有没有办法在将文件添加到暂存区时提供每个文件的注释?
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?
任何人有任何想法我怎么能做到这一点?
回答by Guillaume Darmont
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.
Git 没有提供这样的功能。Git 哲学是跟踪“内容”,而不是“文件”。将文件添加到暂存区允许您准确地准备您的提交。如果将多个文件添加到暂存区,那是因为它们链接到相同的功能。这就是提交消息代表整个更改的原因。
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.
希望这可以帮助。
回答by Katinka Hesselink
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).
上下文:通过$git add .
THEN: 在这个单独的文件 (src/App.js) 上提交消息添加到 git 的多个文件。
[posting answer since this still comes up in google]
[发布答案,因为这仍然出现在谷歌中]
回答by Rajith Jarang
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
回答by Goutham Nammi
In each file in git you will see '+' when you do hover, click on that add your comments for each file.
在 git 中的每个文件中,当您悬停时,您会看到“+”,单击它为每个文件添加注释。