如何解决 git status“未合并路径:”?

发布于 2024-09-09 08:30:50 字数 488 浏览 12 评论 0原文

我将分支 dog 合并到 animal 中。当我提交时,我得到以下信息:

Unmerged paths:
(use "git reset HEAD <file>..." to unstage)
(use "git add <file>..." to mark resolution
both deleted:       ../public/images/originals/dog.ai
added by them:      ../public/images/original_files/dog.ai

每个分支中有不同的目录名和文件名。 animal 分支具有我想要的更改。

当我去重置头部时,它不起作用。当我执行任何其他 git 操作(删除、签出等)时,我收到 path not found 错误。

我需要执行什么命令来解决这个问题?

I merged branch dog into animal. When I go to commit, I get the following:

Unmerged paths:
(use "git reset HEAD <file>..." to unstage)
(use "git add <file>..." to mark resolution
both deleted:       ../public/images/originals/dog.ai
added by them:      ../public/images/original_files/dog.ai

I had different directory names and file names in each branch. The animal branch has the changes that I want.

When I go to reset the head, it doesn't work. And when I go to take any other git action (remove, checkout, etc), I get a path not found error.

What commands do I need to execute to resolve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

笑,眼淚并存 2024-09-16 08:30:50

您需要做的就是:

# if the file in the right place isn't already committed:
git add <path to desired file>

# remove the "both deleted" file from the index:
git rm --cached ../public/images/originals/dog.ai

# commit the merge:
git commit

All you should need to do is:

# if the file in the right place isn't already committed:
git add <path to desired file>

# remove the "both deleted" file from the index:
git rm --cached ../public/images/originals/dog.ai

# commit the merge:
git commit
夏见 2024-09-16 08:30:50

如果你的文件已经签入,并且你的文件已经被合并(但没有提交,因此合并冲突被插入到文件中),处理这种情况的另一种方法是运行:

git reset

这将切换到 HEAD,并告诉 git忘记任何合并冲突,并保持工作目录不变。然后您可以编辑有问题的文件(搜索“更新的上游”通知)。处理完冲突后,您可以运行

git add -p

该命令,这将允许您以交互方式选择要添加到索引的更改。一旦索引看起来不错(git diff --cached),您就可以提交,然后

git reset --hard

销毁工作目录中所有不需要的更改。

Another way of dealing with this situation if your files ARE already checked in, and your files have been merged (but not committed, so the merge conflicts are inserted into the file) is to run:

git reset

This will switch to HEAD, and tell git to forget any merge conflicts, and leave the working directory as is. Then you can edit the files in question (search for the "Updated upstream" notices). Once you've dealt with the conflicts, you can run

git add -p

which will allow you to interactively select which changes you want to add to the index. Once the index looks good (git diff --cached), you can commit, and then

git reset --hard

to destroy all the unwanted changes in your working directory.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文