无法更改分支:由于(已经?)未跟踪文件而合并冲突(Can't change branch: merge conflict because of (already?) untracked fi

系统教程 行业动态 更新时间:2024-06-14 16:58:30
无法更改分支:由于(已经?)未跟踪文件而合并冲突(Can't change branch: merge conflict because of (already?) untracked file)

我已经遇到了无法查看分支的问题(请参阅此处 )。 在我强制结账( git checkout master -f )并进行合并和标记后,我现在想切换回开发分支。 这就是我得到的:

git checkout develop MyProject.userprefs: needs merge error: you need to resolve your current index first

这就是git status给出的:

On branch master Your branch is ahead of 'origin/master' by 78 commits. (use "git push" to publish your local commits) Unmerged paths: (use "git reset HEAD <file>..." to unstage) (use "git add/rm <file>..." as appropriate to mark resolution) deleted by us: MyProject.userprefs no changes added to commit (use "git add" and/or "git commit -a")

我在开头有了MyProject.userprefs文件,但是从开发分支中删除了它并将其添加到.gitignore 。 现在,在master分支中似乎不会忽略该文件。

有趣的是,该文件似乎在索引git ls-files --stage被跟踪了两次:

100644 b16bd8d4e57de7705a5a388d045fed7376a1b175 1 MyProject.userprefs 100644 ef238f895ca1b80f10cfcd45349d82df925ff482 3 MyProject.userprefs

我应该简单地删除MyProject.userprefs吗? 但IDE需要这样做。 我应该在分支中重新创建索引吗?

I already had the problem that I couldn't check out a branch (see here). After I forced the checkout (git checkout master -f) and did the merging and tagging, I now want to switch to the develop branch back. This is what I get:

git checkout develop MyProject.userprefs: needs merge error: you need to resolve your current index first

This is what git status gives:

On branch master Your branch is ahead of 'origin/master' by 78 commits. (use "git push" to publish your local commits) Unmerged paths: (use "git reset HEAD <file>..." to unstage) (use "git add/rm <file>..." as appropriate to mark resolution) deleted by us: MyProject.userprefs no changes added to commit (use "git add" and/or "git commit -a")

I had the file MyProject.userprefs in the beginning, but removed it from develop branch and added it to .gitignore. Now the file seems not to be ignored in the master branch.

What is also interesting is that the file seems to be tracked twice in the index git ls-files --stage:

100644 b16bd8d4e57de7705a5a388d045fed7376a1b175 1 MyProject.userprefs 100644 ef238f895ca1b80f10cfcd45349d82df925ff482 3 MyProject.userprefs

Should I simply delete MyProject.userprefs? But the IDE needs that. Should I recreate the index in the master branch?

最满意答案

我执行了从命令行解决合并冲突中描述的解决方案:

git rm MyProject.userprefs

现在我能够改变分支。

I did the solution described in Resolving a merge conflict from the command line:

git rm MyProject.userprefs

Now I was able to change the branch.

更多推荐

本文发布于:2023-04-15 03:45:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/b3e29fdfe79c26842b23097eecdf00c5.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:分支   冲突   文件   change   branch

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!