2010-08-26 255 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。