git 用主分支中的相同文件覆盖当前分支中的单个文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13847425/
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
Overwrite single file in my current branch with the same file in the master branch?
提问by Abe Miessler
Say I have two branches - master
and redesign
. How would I go about overwriting the file default.aspx.cs
in my redesign branch with the one from master?
假设我有两个分支 -master
和redesign
. 我将如何default.aspx.cs
使用 master 中的文件覆盖我的重新设计分支中的文件?
I found this questionbut it seems to go over how to revert a file back to it's previous version in the same branch. I also considered using a merge
, but I don't want to merge, I want to overwrite. Suggestions?
我发现了这个问题,但它似乎讨论了如何将文件恢复到同一分支中的先前版本。我也考虑过使用 a merge
,但我不想合并,我想覆盖。建议?
回答by Nepomuk Fr?drich
git checkout master path/to/default.aspx.cs
git checkout master path/to/default.aspx.cs
Before doing this, you probably have to : git checkout redesign
在执行此操作之前,您可能必须: git checkout redesign
So, just git checkout FROM_BRANCH_NAME path/to/file
所以就 git checkout FROM_BRANCH_NAME path/to/file