git 无法结帐,文件未合并
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22386030/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cannot checkout, file is unmerged
提问by u2908528
I am trying to remove the file from my working directory but after using the following command
我正在尝试从我的工作目录中删除该文件,但在使用以下命令后
git checkout file_Name.txt
I got the following error message
我收到以下错误消息
error: path 'first_Name.txt' is unmerged
What is that and how to resolve it?
那是什么以及如何解决它?
Following is my git status
以下是我的 git 状态
$ git status
On branch master
You are currently reverting commit f200bf5.
(fix conflicts and run "git revert --continue")
(use "git revert --abort" to cancel the revert operation)
Unmerged paths:
(use "git reset HEAD <file>..." to unstage)
(use "git add <file>..." to mark resolution)
both modified: first_file.txt
Untracked files:
(use "git add <file>..." to include in what will be committed)
explore_california/
no changes added to commit (use "git add" and/or "git commit -a")
采纳答案by brokenfoot
To remove tracked files (first_file.txt) from git:
从 git 中删除跟踪的文件 (first_file.txt):
git rm first_file.txt
And to remove untracked files, use:
要删除未跟踪的文件,请使用:
rm -r explore_california
回答by cristianoms
If you want to discard modifications you made to the file, you can do:
如果要放弃对文件所做的修改,可以执行以下操作:
git reset first_Name.txt
git checkout first_Name.txt
回答by gcb
status tell you what to do.
状态告诉你该怎么做。
Unmerged paths:
(use "git reset HEAD <file>..." to unstage)
(use "git add <file>..." to mark resolution)
you probably applied a stash or something else that cause a conflict.
你可能应用了一个 stash 或其他导致冲突的东西。
either add, reset, or rm.
添加、重置或 rm。
回答by Mahesh Hegde
Following is worked for me
以下对我有用
git reset HEAD
I was getting following error
我收到以下错误
git stash
src/config.php: needs merge
src/config.php: needs merge
src/config.php: unmerge(230a02b5bf1c6eab8adce2cec8d573822d21241d)
src/config.php: unmerged (f5cc88c0fda69bf72107bcc5c2860c3e5eb978fa)
Then i ran
然后我跑了
git reset HEAD
it worked
有效
回答by steven
I don't think execute
我不认为执行
git rm first_file.txt
is a good idea.
是个好主意。
when git notice your files is unmerged, you should ensure you had committed it.
And then open the conflict file:
cat first_file.txt
fix the conflict
当 git 注意到你的文件未合并时,你应该确保你已经提交了它。
然后打开冲突文件:
cat first_file.txt
解决冲突
4.
4.
git add file
git add file
git commit -m "fix conflict"
5.
git push
5.
git push
it should works for you.
它应该适合你。
回答by alant
In my case, I found that I need the -f option. Such as the following:
就我而言,我发现我需要 -f 选项。例如以下内容:
git rm -f first_file.txt
to get rid of the "needs merge" error.
摆脱“需要合并”错误。