2013-08-18 76 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 
相关问题