Git: can't undo local changes (error: path … is unmerged)

╄→гoц情女王★ 提交于 2019-11-28 02:39:05

You did it the wrong way around. You are meant to reset first, to unstage the file, then checkout, to revert local changes.

Try this:

$ git reset foo/bar.txt
$ git checkout foo/bar.txt
Steffi

This worked perfectly for me:

$ git reset -- foo/bar.txt
$ git checkout foo/bar.txt
git checkout origin/[branch] .
git status

// Note dot (.) at the end. And all will be good

git checkout foo/bar.txt

did you tried that? (without a HEAD keyword)

I usually revert my changes this way.

I find git stash very useful for temporal handling of all 'dirty' states.

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