2014-03-13 30 views
29

我想從我的工作目錄刪除該文件,但使用以下命令無法檢出,文件是未合併

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") 
+2

'git的RM file1.txt' – brokenfoot

+0

感動到臨時索引,但如果你想刪除'explore_california'然後就做了'RM我是無法清除的文件夾explore_california/ –

+1

- r explore_california',因爲它沒有被git跟蹤。 – brokenfoot

回答

16

從混帳刪除文件履帶(first_file.txt):

git rm first_file.txt 

,並刪除未跟蹤文件,請使用:

rm -r explore_california 
14

狀態告訴你該怎麼做。

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

您可能應用了隱藏或導致衝突的其他內容。

要麼添加,重置或rm。

3

我不認爲執行

git rm first_file.txt 

是一個好主意。

  1. 當git注意到你的文件未被合併時,你應該確保你已經提交了它。

  2. 然後打開衝突文件:

    cat first_file.txt

  3. 解決衝突

4.

git add file

git commit -m "fix conflict" 

5. git push

它應該爲你的作品。

51

如果你要放棄你對文件所作的修改,你可以這樣做:

git reset first_Name.txt 
git checkout first_Name.txt 
0

以下是我

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 

它的工作