2014-01-26 62 views
22

Git不会让我从任何地方重新绑定。Git:因为未提交的更改而无法重新绑定

Cannot rebase: Your index contains uncommitted changes. 
Please commit or stash them. 

继从这个答案说明:https://stackoverflow.com/a/13694625/618450

$ git update-index -q --ignore-submodules --refresh 
$ git diff-files --ignore-submodules 

双方不产生任何输出,但一个作用:

$ git diff-index --cached --ignore-submodules HEAD -- 
:100644 000000 cab819f1e5ed6cc7cff374eecae273e1d6ae6a01  0000000000000000000000000000000000000000 D .idea/codeStyleSettings.xml 
:100644 000000 2953f353d2c65dd62e36926accb7f645a600b7e0 0000000000000000000000000000000000000000 D .idea/dictionaries/roxy.xml 
:100644 000000 0e7ecef362d8a77067edf4bae5972f33185bd986 0000000000000000000000000000000000000000 D .idea/inspectionProfiles/Project_Default.xml 
:100644 000000 3b312839bf2e939fea3ebdef15630a4b33e57caf 0000000000000000000000000000000000000000 D .idea/inspectionProfiles/profiles_settings.xml 
:100644 000000 e31af55b33d82e28f471a2ba51b63c2a91fa53b7 0000000000000000000000000000000000000000 D .idea/php.xml 
:100644 000000 9c25e8d4f1169b5d3103b14fdb60e7d7c3975b70 0000000000000000000000000000000000000000 D db/sfront.sql 

,我无法删除这些文件:

$ git rm --cached .idea/php.xml 
fatal: pathspec '.idea/php.xml' did not match any files 

任何可以帮助我的想法?

编辑: git的藏匿

固定我的问题。我不确定我是否理解发生了什么。它抱怨的文件应该被忽略。

+2

'git的stash',然后呢? – Ryan

+0

看起来像修复它,谢谢。 – Pixy

+0

文件不能同时被忽略*和*成为您的存储库的一部分。如果'git'检测到这些文件发生了变化,那么它们以前被添加到存储库中(这意味着即使它们被列在'.gitignore'中也不会被忽略 - 你告诉'git'它们很重要,毕竟)。 – larsks

回答

41

git stash将不同的文件存储在远离其他任何地方的位置,将您的工作目录返回到上次提交。一旦你完成你的rebase,运行git stash pop。这会将这些文件返回到工作目录,并允许您像以前一样工作。

编辑:一个好的链接,学习所有关于git stash命令:Git Tools - Stashing

+1

感谢您的澄清。我还有一个问题,当我试图提交git时说它没有找到任何改变。为什么提交没有看到任何更改,但存储呢? – Pixy

+0

你以后做过'git stash pop'吗? – jamesthollowell

+1

不,我不需要这些文件。 .idea中的所有文件都来自我的IDE和我的db的旧备份。如果他们留在藏匿处,将来会导致我的问题? – Pixy

相关问题