git 无法 checkout ,文件未合并

iugsix8n  于 2023-01-15  发布在  Git
关注(0)|答案(9)|浏览(202)

我正尝试从工作目录中删除该文件,但在使用以下命令后

git checkout file_Name.txt

我收到以下错误消息

error: path 'first_Name.txt' is unmerged

这是什么?如何解决?
以下是我的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")
omtl5h9j

omtl5h9j1#

如果要放弃对文件所做的修改,可以执行以下操作:

git reset first_Name.txt
git checkout first_Name.txt
4nkexdtk

4nkexdtk2#

从git中删除被跟踪的文件(first_file. txt):

git rm first_file.txt

要删除未跟踪的文件,请用途:

rm -r explore_california
woobm2wo

woobm2wo3#

以下内容对我很有效

git reset HEAD

我收到波纹管错误

git stash
src/config.php: needs merge
src/config.php: needs merge
src/config.php: unmerge(230a02b5bf1c6eab8adce2cec8d573822d21241d)
src/config.php: unmerged (f5cc88c0fda69bf72107bcc5c2860c3e5eb978fa)

然后我跑了

git reset HEAD

成功了

sbdsn5lh

sbdsn5lh4#

状态会告诉您该做什么。

Unmerged paths:
  (use "git reset HEAD <file>..." to unstage)
  (use "git add <file>..." to mark resolution)

你可能藏了什么东西或者其他什么引起了冲突。
添加、复位或RM。

z3yyvxxp

z3yyvxxp5#

我不认为处决

git rm first_file.txt

是个好主意。
1.当git注意到你的文件被取消合并时,你应该确保你已经提交了它。
1.然后打开冲突文件:
cat first_file.txt
1.解决冲突
4.
git add file

git commit -m "fix conflict"
  1. git push
    应该对你有用。
ua4mk5z4

ua4mk5z46#

第一步:

git stash -u

第二步:

git stash drop stash@{1}

第三步:

git checkout .
hwazgwia

hwazgwia7#

在我的例子中,我发现我需要-f选项,例如:

git rm -f first_file.txt

以消除“需要合并”的错误。

bnlyeluc

bnlyeluc8#

我解决了做以下2个简单的步骤:
步骤1:git重置Head步骤2:git添加。

k7fdbhmy

k7fdbhmy9#

对我很有效。
它将从货币头部恢复文件

git restore -S -W file_Name.txt

相关问题