Git:由于未提交的更改,无法重新绑定

时间:2014-01-26 02:24:06

标签: git git-rebase

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 stash

解决了我的问题。我不确定我明白发生了什么。它抱怨的文件应该被忽略。

2 个答案:

答案 0 :(得分:47)

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

编辑:学习所有git stash命令的良好链接:Git Tools - Stashing

答案 1 :(得分:0)

可能还没有金铲子,但是在重新提交未提交的更改时,我总是使用--autostash选项,因此:

  

git rebase --interactive SHA_WHERE_REBASE_ONTO^ --autostash