什么将“被合并覆盖"?意思是? [英] What does "would be overwritten by merge" mean?

查看:133
本文介绍了什么将“被合并覆盖"?意思是?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从基于团队的Git远程存储库中提取信息时,我得到以下消息:

When pulling from a team based Git remote repository, I get this message:

"C:\Program Files (x86)\Git\bin\git.exe" pull --progress "origin" +refs/heads/master:refs/remotes/origin/master
Updating 71089d7..4c66e71
error: Your local changes to the following files would be overwritten by merge:
    Source/Reporting/Common/Common.Dal.csproj
Please, commit your changes or stash them before you can merge.
Aborting
Done

Git中的哪些规则(或功能)可确保我在工作目录中修改的文件不会被拉动覆盖?

What rule (or feature) in Git makes sure that the file I modified in my working directory does NOT get overwritten by the pull?

换句话说,在什么情况下会被拉动覆盖?还是...我该怎么做才能强制拉取以覆盖我刚刚修改的文件?

In other words, in what circumstances it will be overwritten by a pull? or... what do I need to do to force a pull to overwrite the file I just modified?

推荐答案

什么规则将产生将被覆盖"警告?

如果您修改了在远程存储库中也进行了修改但尚未提交的文件.

What rule would produce a "would be overwritten" warning?

If you've modified a file that also have modifications in the remote repository but have not committed it.

如果没有未提交的文件在远程仓库中也进行了修改.

If there are no uncommitted files that also have modifications in the remote repo.

这取决于您的实际需求:

It depends on what you actually want:

  1. 您要强制拉动以覆盖文件

很显然,如果您确实想要这样做,则不必关心您刚刚进行的更改,也不想删除它们.如果是这样,您只需这样做:

Obviously, if you really want this, you don't care about the changes you've just made and don't mind deleting them. If so you simply do:

git reset --hard
git pull

  • 您既要进行更改,又要从下拉菜单中进行更改

    在我看来,处理此问题最简单的方法是先提交更改,然后再进行拉动.然后,如果存在合并冲突,请使用通常的机制来解决合并(提示:配置difftool和mergetool,以便您可以使用GUI工具(例如,meld或diffmerge等)轻松解决冲突).只要做:

    The easiest way to handle this in my opinion is to commit your changes then do a pull. Then if there is a merge conflict use the usual mechanisms to resolve the merge (hint: configure your difftool and mergetool so you can easily resolve conflicts using a GUI tool like meld or diffmerge etc.). Just do:

    git add $the_affected_file
    git commit
    git pull
    

  • 您需要两个更改,但还没有准备好提交

    我个人认为您不应该准备提交.但是,有时您调试的代码部分损坏,而您确实不想提交,这是不时发生的.在这种情况下,您可以暂时存储更改,然后在拉出后取消存储:

    Personally I don't think you should ever be not ready to commit. But it happens from time to time that you have partly broken code that you're debugging and you really don't want to commit. In this case you can stash you changes temporarily then unstash it after pulling:

    git stash
    git pull
    git stash pop
    

    如果在弹出存储区后有冲突,请按照通常的方法解决.注意:如果您由于冲突而还没有准备好丢失隐藏的代码,则可能需要使用git stash apply而不是pop.

    If there are conflicts after popping the stash resolve them in the usual way. Note: you may want to do a git stash apply instead of pop if you're not ready to lose the stashed code due to conflicts.

    这篇关于什么将“被合并覆盖"?意思是?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆