2010-08-26 252 views
2
$ git --version 
git version 1.7.0.3 

我克隆一個SVN倉庫,並作出承諾:git svn dcommit總是失敗,「無法用髒索引提交。」

$ git svn clone --stdlayout http://svn/example/project 
$ echo test >> blah.txt 
$ git commit -m "Something" 

當我嘗試和dcommit回SVN,我得到以下錯誤:

$ git svn dcommit 
Cannot dcommit with a dirty index. Commit your changes first, or stash them with `git stash'. 
at .../git/1.7.0.3/.../libexec/git-core/git-svn line 497 

..despite的分支似乎很乾淨:

$ git status 
# On branch master 
nothing to commit (working directory clean) 

唯一的地方我ca N參看子虛烏有的「未分級的變化」是gitk,它說:「本地提交的修改,在索引未選中」

運行git stash允許dcommit出於某種原因的工作:

$ git stash 
No local changes to save 
$ git svn dcommit 
Committing to http://svn/example/project ... 
     M  blah.txt 
Committed r65913 
     M  blah.txt 
r65913 = a5547d761108d233211f115429e23ddca73bf4bc (refs/remotes/trunk) 
No changes between current HEAD and refs/remotes/trunk 
Resetting to the latest refs/remotes/trunk 

我有一個別名運行git stash; git svn dcommit; git stash apply - 但這不是最好的解決方法,因爲它會導致使用實際使用藏匿

+0

3年後,我遇到了同樣的事情。不幸的是,情況變得更糟。 git暗藏不允許我dcommit。 – 2013-10-08 16:33:49

+0

%git svn dcommit fatal:歧義參數'HEAD':修訂版本和文件名稱 使用' - '將文件名與修訂版本分開 無法提交髒索引。首先提交你的修改,或者用'git stash'隱藏它們。 git-core/git-svn line 760 – 2013-10-08 16:42:14

回答

3

當我寫這個問題時,合併的錯誤,我發現了以下承諾:

http://repo.or.cz/w/git.git/commitdiff/181264ad590ffef9d956fdd023369869c2d0a55f

The dcommit command fails if an otherwise unmodified file has been touched in the working directory:

Cannot dcommit with a dirty index. Commit your changes 
first, or stash them with `git stash'. 

This happens because "git diff-index" reports a difference between the index and the filesystem:

:100644 100644 d00491...... 000000...... M  file 

The fix is to run "git update-index --refresh" before "git diff-index" as is done in git-rebase and git-rebase--interactive before "git diff-files".

This changes dcommit to display a list of modified files before exiting.

Also add a similar test case for "git svn rebase".

無法從混帳破譯日誌的變化是什麼版本,但它看起來像變化後應1.7.2.2

編輯在版本:截至11月19日,2011年,承諾仍然只是在主分支:

$ git branch --contains 181264ad590ffef9d956fdd023369869c2d0a55f 
* master 

EDIT2:現在這種變化是在GI噸1.7.3起

> git tag --contains 181264ad590ffef9d956fdd023369869c2d0a55f | sort -V 
v1.7.3 
[...] 
+0

git update-index --refresh不能幫助我,而且我使用的是git 1.7.9。 – 2013-10-08 16:35:13

0

我收到類似的錯誤,當我試圖執行git svn dcommit

我試圖從非根git文件夾(其中包含.git -subfolder)和SVN回購更改,我還沒有檢索到通過git svn rebase git。