2013-08-18 75 views
0

我試圖pull origin a如何忽略已經在git中跟蹤的文件

去以下:

error: Your local changes to the following files would be overwritten by merge: 
    src/.cproject 
    src/.project 
    src/navigate/navigate_main.c 
Please, commit your changes or stash them before you can merge. 
Aborting 

git的狀態顯示:

modified: .gitignore 
modified: src/.cproject 
modified: src/.project 
modified: src/navigate/navigate_main.c 

我做git rm --cached src/.project前3,和stashed第四

我再次拉和unstashed我變化。

但是當我做pull origin a

我得到:

M .gitignore 
U src/.cproject 
M src/navigate/navigate_main.c 
Pull is not possible because you have unmerged files. 
Please, fix them up in the work tree, and then use 'git add/rm <file>' 
as appropriate to mark resolution, or use 'git commit -a'. 

如何清潔這種一勞永逸?

+0

您修改了文件,這些文件與服務器上的文件不同。首先合併這些文件。然後提交。然後拉。 –

回答

0

git rm --cached src/.project沒有做太多好處,除非你commit的變化。爲什麼不只是git stash的一切,然後pull,stash pop,然後用rm --cached刪除被忽略的文件?

+0

我總是在'.cproject'上合併衝突,因爲我的eclipse項目命名與我的同事不同。我們每個人都以不同的名字開始,這就是爲什麼我們的項目命名不同。 –

+0

如果你將你的開發環境與你的合作者統一起來,你將會爲自己節省很多頭痛。 – dahlbyk

0

未提交的更改總是不好的。你必須決定這些變化是好還是壞。如果他們是好的,就承諾吧。如果不好,丟棄它們。

一旦你沒有更多的未提交更改,你沒有更多的問題。

查看git statusgit status --short以查看任何未提交的更改。

配置一個有意義的提示,以便立即查看正在進行的操作。 對於bash添加像這樣到你的〜/ .bashrc:

PS1='[\[email protected]\h \W$(__git_ps1 " (%s)")]\$ ' 
GIT_PS1_SHOWDIRTYSTATE=yes 
GIT_PS1_SHOWSTASHSTATE=yes 
GIT_PS1_SHOWUNTRACKEDFILES=yes 
GIT_PS1_SHOWUPSTREAM=auto 
相關問題