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

前端 未结 5 945
没有蜡笔的小新
没有蜡笔的小新 2020-12-13 09:21

I am trying to pull changes from remote branch but getting an error which doesn\'t make sense

when I do

git pull

I get back

<
相关标签:
5条回答
  • 2020-12-13 10:00
    1. Delete the problematic files.
    2. Run git reset --hard.

    That should fix it.

    0 讨论(0)
  • 2020-12-13 10:00

    I had the same problem but with the .idea / vcs.xml and workspace.xml files. I deleted the 2 files then used the command: - git pull "remote" "brench"

    0 讨论(0)
  • 2020-12-13 10:04

    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
    0 讨论(0)
  • 2020-12-13 10:19

    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
    
    0 讨论(0)
  • 2020-12-13 10:25

    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.

    0 讨论(0)
提交回复
热议问题