[英]Git. Rebase local branch atop local master. How do I ignore a single files changes?
With Git I am on a branch. 有了Git我就在一个分支上。 I am rebasing the branch atop master. 我正在重新掌握主人的分支。 There is a conflict that I want to resolve by ignoring the branches version and accepting master's version. 我想通过忽略分支版本和接受主版本来解决冲突。 How do I indicate I want to use master's version of the file during the rebase-ing. 如何指示我想在重新定义期间使用主文件版本的文件。
Thanks, 谢谢,
Doug 道格
git checkout --ours <path-to-file>
is the command you are looking for. git checkout --ours <path-to-file>
是您要查找的命令。
It will checkout the master version of the file which you then can add to the index (to mark the conflict resolved) and continue your rebase. 它将检出文件的主版本,然后您可以将其添加到索引(以标记已解决的冲突)并继续您的rebase。
You can take a look at the checkout documentation for more information. 您可以查看结帐文档以获取更多信息。
See the comment under --merge
as to why you need to use --ours
and not --theirs
. 请参阅--merge
下的注释, --merge
为什么需要使用--ours
而不是--theirs
。
git checkout --ours filenamewithpath
如果你想保持当前分支文件使用git checkout --ours filenamewithpath
If you want to keep other branch file use git checkout --theirs filenamewithpath
如果你想保留其他分支文件使用git checkout --theirs filenamewithpath
Please check this link http://gitready.com/advanced/2009/02/25/keep-either-file-in-merge-conflicts.html 请查看此链接http://gitready.com/advanced/2009/02/25/keep-either-file-in-merge-conflicts.html
Just in case anyone stucks as myself. 以防万一有人像我一样陷入困境。
If you want to override all your local changes with "theirs", it is probably because someone removed a commit your local branch was referred to and added a new one and you're doing a rebase, so that git tries to apply (this old commit + yours) on top of theirs. 如果你想用“他们的”覆盖你所有的本地更改,可能是因为有人删除了你的本地分支被引用的提交并添加了一个新的你正在做一个rebase,所以git尝试应用(这个旧的他们之上的承诺+你的。
In this case use git rebase -i remote-branch
and comment out the old commit. 在这种情况下,使用git rebase -i remote-branch
并注释掉旧提交。
Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.