Git pull error: Your local changes to the following files would be overwritten by merge:

北城余情 提交于 2019-11-28 19:14:45

I had this same issue, and the fetch/rebase answer didn't work for me. Here's how I solved it:

I deleted the file that was causing the issue, checked it out, and then pulled successfully.

  1. rm file/name/path/some/more/filenamepath
  2. git checkout file/name/path/some/more/filenamepath
  3. git pull
Dan
  1. Delete the problematic files.
  2. Run git reset --hard.

That should fix it.

VonC

You should:

  • fetch (updating all remote tracking branches, like origin/master)
  • rebase your current branch on top of origin/master in order to replay your 2 commits on top of the 7 updated commits that you just fetched.

That would be:

git checkout master
git fetch
git rebase origin/master

A shorter version of the above set of commands would be the following single command:

git pull --rebase

Had the same issue. Solved it by re-cloning the repo. But now I think that the reason was the line endings in these files. I played with them before.

I suppose that line-ending difference doesn't mark files as changed, but may lead to this message. When you rm the files and recheckout them, line endings should set to "good state", and pull goes fine.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!