如何让git提交“我们删除”文件?

时间:2018-01-22 23:22:45

标签: git

我正在尝试合并,deleted by us标题下有几个Unmerged paths:的文件。它对use "git add/rm <file>..." as appropriate to mark resolution说。

奇怪的是,我认为上次我被对象删除时,我使用了mergetool,它会询问我是要删除它还是取本地,但mergetool不起作用,它陈述No files need merging。我尝试过的其他事情是:

  • 使用git add _filename_会导致文件被添加到舞台区域。不是我想要的。
  • 使用git rm _filename_会产生fatal: pathspec '_filename_' did not match any files.
  • 如果我添加文件然后执行git rm -f _filename_它会删除文件,但是我应该怎么做呢?

我觉得在我的本地存储库中有些东西已经消失了。任何人都可以确认吗?

1 个答案:

答案 0 :(得分:0)

一个简单的git rm应该足够了(虽然它有点抱怨)。我为名为file的文件

设置了合并冲突
$ git merge sidebr
CONFLICT (modify/delete): file deleted in HEAD and modified
 in sidebr. Version sidebr of file left in tree.
Automatic merge failed; fix conflicts and then commit the result.
$ git status
On branch master
You have unmerged paths.
  (fix conflicts and run "git commit")
  (use "git merge --abort" to abort the merge)

Unmerged paths:
  (use "git add/rm <file>..." as appropriate to mark resolution)

        deleted by us:   file

no changes added to commit (use "git add" and/or "git commit -a")
$ git rm file
file: needs merge
rm 'file'
$ git status
On branch master
All conflicts fixed but you are still merging.
  (use "git commit" to conclude merge)

如果您的情况不同,如果您提供了更多设置信息和/或实际会话的记录,如上所述,将会有所帮助。