git - 为什么 Git 说文件是 'deleted by us' 而我还没有碰它?

标签 git

我调整了2个文件,然后去 merge 到Github。但是,当我运行推送时出现错误:

Unmerged paths:
#   (use "git add/rm <file>..." as appropriate to mark resolution)
#       deleted by us:   somefolder/somefile.ext

但是,我没有动过这个文件。查看我的本地目录时,我发现该文件仍然完好无损。

有人知道为什么会发生这种情况以及我能做些什么吗?

最佳答案

参见“Who is “us” according to git?

When you merge, us refers to the branch you're merging into, as opposed to them, the branch to be merged.

所以目标分支应该删除这个文件。

请参阅“git merge “deleted by us””以获取解决方案:您可以将其添加回去或​​将其删除。

作为torek details ,在这种情况下(您没有自己删除文件)中的“我们”表示 rebase (如 git pull --rebase)。

参见“git rebase, keeping track of 'local' and 'remote'

  • 本地(“我们”)引用部分重新设置基数的提交:“我们的”(上游分支)
  • 远程(“他们”)指的是传入的更改:“他们的”- rebase 之前的当前分支,即您没有删除该文件的分支。

关于git - 为什么 Git 说文件是 'deleted by us' 而我还没有碰它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44015527/

相关文章:

windows - 从 github 克隆存储库失败

git - 是否可以在没有 git clone 的情况下获取远程 git repo 的提交日志/消息

git - 在 ubuntu 18.04.2LTS 中安装 git 时出现错误

xml - 使用 git 和 xml 数据的协作环境

git - 来自 Jenkins 字符串参数的存储库 URL

使用相对 URL 的 Git 子模块

linux - 如何在 Linux 上将 git 更新到最新版本?

java - Git:重构文件名后无法清理工作副本

git推送原始主机: 'D:/Projects/TheProject' is not a git command

node.js - npm 警告没有存储库字段