代码之家  ›  专栏  ›  技术社区  ›  dbr

git svn dcommit总是失败,并显示“无法用脏索引进行dcommit”。

  •  2
  • dbr  · 技术社区  · 14 年前
    $ git --version
    git version 1.7.0.3
    

    我克隆了一个SVN存储库,并提交:

    $ 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
    

    …尽管树枝看起来很干净:

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

    我唯一能看到不存在的“未经改变”的地方是 gitk ,其中显示“本地未提交的更改,未签入到索引”

    运行 git stash 允许 德班特 为了某种原因工作:

    $ 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 -但这不是最好的解决方法,因为它在实际使用stash时会导致合并错误。

    2 回复  |  直到 9 年前
        1
  •  3
  •   dbr    9 年前

    在我写这个问题的时候,我发现了以下承诺:

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

    如果 否则未修改的文件 在工作目录中触摸:

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

    这是因为“git diff索引” 报告索引之间的差异 文件系统:

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

    修复方法是运行“git更新索引” --在“git diff index”之前刷新,如在git-rebase中所做的,以及 Git-Rebase--在“Git”之前交互 差异文件“。

    这将更改dcommit以显示列表 在退出之前修改了个文件。

    还为“git”添加类似的测试用例 SvnReBase.

    无法从Git日志中破译更改所在的版本,但看起来更改应该在之后的版本中 1.7.2.2

    编辑: 截至2011年11月19日,该承诺仍仅在主分支机构:

    $ git branch --contains 181264ad590ffef9d956fdd023369869c2d0a55f
    * master
    

    编辑2: 这一变化现在在1.7.3吉特以后。

    > git tag --contains 181264ad590ffef9d956fdd023369869c2d0a55f | sort -V
    v1.7.3
    [...]
    
        2
  •  0
  •   sergtk    10 年前

    我在尝试执行时收到类似的错误 git svn dcommit .

    我试图从非根Git文件夹(其中包含 .git -子文件夹)和SVN报告中的更改,我还没有通过 git svn rebase .