Git没有显示任何冲突,并且正在覆盖我的本地副本 [英] Git is not showing any conflicts, and is overwriting my local copy

查看:298
本文介绍了Git没有显示任何冲突,并且正在覆盖我的本地副本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在git上的例程总是非常简单:

My routine on git has always been very simple:

git add -A
git commit -m 'the changes I made'
git pull
# resolve conflicts
git push

但是,由于某些未知的原因,尽管与原点存在很多冲突,但是在拉动之后,我没有任何冲突,并且在未经我允许的情况下,它会强制更新我的本地副本.这些内容包括:'2个文件已更改,2个插入(+),6个删除(-)'.但就我而言,不应通过简单的合并解决冲突,而应从我这一方面要求手动解决冲突.为什么git不让我做手动冲突解决方案?提前致谢! 注意:我的git命令都没有强制选项-f

However, for some unknown reasons, despite lots of conflicts with the origin, after pulling, I don't get any conflicts and without my permission it force updates my local copy. Something along these lines: '2 files changed, 2 insertions(+), 6 deletions(-)'. But in my case, conflicts shouldn't be resolved from simple merge and should require manual conflict resolution from my side. Why is git not letting me to do the manual conflict resolution? Thanks in advance! note: none of my git commands have force option -f

推荐答案

git pull或多或少地等同于git fetch && git merge origin/<upstream_branch>.通过使用pull而不是fetchmerge,可以允许git尝试合并到本地分支中.如果该合并发生而没有冲突,则您的本地计算机将显示为强制更新",因为它能够在无需您干预的情况下整理出远程文件版本与您自己文件版本之间的差异.

git pull without argument is, more or less, equivalent to git fetch && git merge origin/<upstream_branch>. By using pull instead of fetch and merge, you're allowing git to attempt the merge into your local branch. If that merge occurs without conflict, your local will look "force updated" because it was able to sort out the differences between the remote's version of your files and your own, without your intervention.

调试正在发生的事情很困难,而又看不到您的代码,但是请尝试以下操作:

Debugging what's happening is sort of hard without seeing your code, but try this:

git fetch ;# fetch the remote changes
git diff HEAD origin/<branch> ;# diff your local branch with the remote's copy of <branch>

git diff的输出将使您了解正在发生的事情.如果您想进一步遵循它,请尝试git merge --no-commit origin/<branch>,然后发出git diff --cached.这将向您确切显示git自动合并的更改,并应让您确定是什么.

The output from git diff should clue you into what's happening. If you'd like to follow it even further, try git merge --no-commit origin/<branch>, then issue git diff --cached. That'll show you exactly what changes git merged automatically, and should allow you to determine what's what.

这篇关于Git没有显示任何冲突,并且正在覆盖我的本地副本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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