git 使用 Visual Studio 2015,如何只提交一个文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37029523/
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
Using Visual Studio 2015, how to commit only one file?
提问by Ryan Betker - healthNCode
What I've tried: I don't recall to have an issue when in VS2013. When in VS2015, I've tried the context menu inside one code file or right clicking just that file from Solution Explorer, yet it includes all changed files.
我尝试过的:我不记得在 VS2013 中遇到过问题。在 VS2015 中,我尝试在一个代码文件中使用上下文菜单或从解决方案资源管理器中右键单击该文件,但它包含所有更改的文件。
I've also tried filtering and that doesn't help narrow down the checkin.
我也尝试过过滤,但这无助于缩小签入范围。
采纳答案by Konst
View->Other windows->Pending Changes
Then exclude whichever file you do not want to commit.
然后排除您不想提交的任何文件。
回答by Jay Adams
If you're using Git with Visual Studio 2015, from Team Explorer, right-clickon just the file(s) you want to commit and select Stage.
如果您在 Visual Studio 2015 中使用 Git,请从Team Explorer 中,仅右键单击要提交的文件并选择Stage。
Now you'll have a new section above Changes called Staged Changesthat only contain the file(s) you want. Type in your commit message and then select Commit Staged. Everything else will still be untouched under Changes.
现在,您将在 Changes 上方有一个名为Staged Changes的新部分,其中仅包含您想要的文件。输入您的提交消息,然后选择Commit Staged。在 Changes 下,其他所有内容仍将保持不变。
回答by Igor Pavlichenko
OR, or, you can always do this in git bash(windows). Make sure you open git bash in your project folder and type following commands:
或者,或者,您始终可以在 git bash(windows) 中执行此操作。确保在项目文件夹中打开 git bash 并键入以下命令:
$ git add fileToCommit.extension
$ git commit -m "This is my commit message"
Push when you are done:
完成后按下:
$ git push