无法结账,文件未合并

李 *_* 慕 58 git

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

git checkout file_Name.txt
Run Code Online (Sandbox Code Playgroud)

我收到以下错误消息

error: path 'first_Name.txt' is unmerged
Run Code Online (Sandbox Code Playgroud)

那是什么以及如何解决它?

以下是我的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")
Run Code Online (Sandbox Code Playgroud)

cri*_*oms 88

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

git reset first_Name.txt
git checkout first_Name.txt
Run Code Online (Sandbox Code Playgroud)

  • 我认为使用双连字符“git reset --first_Name.txt”和“git checkout --first_Name.txt”更安全,以防文件名与您的分支/标签/提交之一相同。 (4认同)
  • 需要双连字符 arg 吗?git reset -- first_name.txt 和 git checkout -- first_name.txt (2认同)
  • 您只需使用`--`将要检出的树与要检出的文件分开.要进行更深入的解释,请在此处获取战利品:/sf/ask/932502091/ (2认同)

bro*_*oot 19

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

git rm first_file.txt
Run Code Online (Sandbox Code Playgroud)

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

rm -r explore_california
Run Code Online (Sandbox Code Playgroud)


gcb*_*gcb 16

状态告诉你该怎么做.

Unmerged paths:
  (use "git reset HEAD <file>..." to unstage)
  (use "git add <file>..." to mark resolution)
Run Code Online (Sandbox Code Playgroud)

你可能应用了藏匿或其他导致冲突的东西.

添加,重置或rm.

  • 正是我应用了一个藏匿处。现在的问题是什么时候使用`add`,什么时候使用`reset`,什么时候使用`rm`?例如,我不想保留隐藏版本,而是保留来自上游的版本? (2认同)

Mah*_*gde 7

以下对我有用

git reset HEAD
Run Code Online (Sandbox Code Playgroud)

我遇到以下错误

git stash
src/config.php: needs merge
src/config.php: needs merge
src/config.php: unmerge(230a02b5bf1c6eab8adce2cec8d573822d21241d)
src/config.php: unmerged (f5cc88c0fda69bf72107bcc5c2860c3e5eb978fa)
Run Code Online (Sandbox Code Playgroud)

然后我跑了

git reset HEAD
Run Code Online (Sandbox Code Playgroud)

有效