git不能撤销本地修改(error:path…is unmerged)

发布时间:2023-02-21 23:45:41 阅读:1903次

最近在使用git的时候提示以下错误

$ git status foo/bar.txt
# On branch master
# Unmerged paths:
# (use"git reset HEAD <file>..." to unstage)
# (use"git add/rm <file>..." as appropriate to mark resolution)
#
# deleted by us: foo/bar.txt
#
no changes added to commit (use"git add" and/or"git commit -a")

文件foo/bar.txt存在,並且我希望將它重新設置為"unchanged state",然後('複製到:

$ git checkout HEAD foo/bar.txt
error: path 'foo/bar.txt' is unmerged
$ git reset HEAD foo/bar.txt
Unstaged changes after reset:
M foo/bar.txt

$ git status foo/bar.txt
# On branch master
# Changes to be committed:
# (use"git reset HEAD <file>..." to unstage)
#
# new file: foo/bar.txt
#
# Changed but not updated:
# (use"git add <file>..." to update what will be committed)
# (use"git checkout -- <file>..." to discard changes in working directory)
#
# modified: foo/bar.txt

解决方式 还原

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

如有问题,可以QQ搜索群1028468525加入群聊,欢迎一起研究技术

支付宝 微信

有疑问联系站长,请联系QQ:QQ咨询

转载请注明:git不能撤销本地修改(error:path…is unmerged) 出自老鄢博客 | 欢迎分享