无法更改分支:合并冲突,因为(已经?)未跟踪的文件
Can't change branch: merge conflict because of (already?) untracked file
我已经遇到无法签出分支的问题(请参阅 )。在我强制结帐 (git checkout master -f
) 并进行合并和标记之后,我现在想切换回 develop 分支。这是我得到的:
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
,但将其从 develop 分支中删除并添加到 .gitignore
。现在该文件似乎在 master 分支中不会被忽略。
同样有趣的是,该文件似乎在索引中被跟踪了两次 git ls-files --stage
:
100644 b16bd8d4e57de7705a5a388d045fed7376a1b175 1 MyProject.userprefs
100644 ef238f895ca1b80f10cfcd45349d82df925ff482 3 MyProject.userprefs
我应该直接删除 MyProject.userprefs 吗?但是 IDE 需要那个。我应该在 master 分支中重新创建索引吗?
我做了 Resolving a merge conflict from the command line 中描述的解决方案:
git rm MyProject.userprefs
现在我可以更改分支了。
我已经遇到无法签出分支的问题(请参阅 git checkout master -f
) 并进行合并和标记之后,我现在想切换回 develop 分支。这是我得到的:
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
,但将其从 develop 分支中删除并添加到 .gitignore
。现在该文件似乎在 master 分支中不会被忽略。
同样有趣的是,该文件似乎在索引中被跟踪了两次 git ls-files --stage
:
100644 b16bd8d4e57de7705a5a388d045fed7376a1b175 1 MyProject.userprefs
100644 ef238f895ca1b80f10cfcd45349d82df925ff482 3 MyProject.userprefs
我应该直接删除 MyProject.userprefs 吗?但是 IDE 需要那个。我应该在 master 分支中重新创建索引吗?
我做了 Resolving a merge conflict from the command line 中描述的解决方案:
git rm MyProject.userprefs
现在我可以更改分支了。