简体   繁体   English

Git的。 在本地主服务器上重新启动本地分支。 如何忽略单个文件更改?

[英]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

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.

相关问题 意外将远程分支合并到本地主服务器。 我该如何退出? - Accidentally merged remote branch to local master. How do I back out? 主机中本地未提交的更改。 需要切换到另一个分支 - Local uncommited changes in master. Need to switch to another branch 当我有本地文件更改时,如何在较少的命令中从master获取rebase - How do I git rebase from master in fewer commands when I have local file changes git将本地分支重新建立到远程主服务器 - git rebase local branch to remote master git将原始分支基于原点/主节点 - git rebase local branch on origin/master 本地分支中git rebase master的意外结果 - Unexpected result of git rebase master in local branch 我有一个分支的git repo:master。 如何在本地和远程仓库上重命名分支? - I have git repo with one branch: master. How do I rename the branch locally and on the remote repo? 如何将本地 Git 分支推送到远程的 master 分支? - How do I push a local Git branch to master branch in the remote? git如何变基 <repo><branch> 将更改应用于本地 - How does git rebase <repo> <branch> apply changes to local 如何检出远程分支,将其重新建立为本地主机,然后与本地主机合并? - How to checkout a remote branch, rebase it to local master and then merge with local master?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM