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

发布于 2024-09-16 01:06:10 字数 1165 浏览 2 评论 0原文

$ 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 允许 dcommit code> 由于某种原因工作:

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

$ git --version
git version 1.7.0.3

I clone an SVN repository, and make a commit:

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

When I try and dcommit back to the SVN, I get the following error:

$ 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 the branch being seemingly clean:

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

The only place I can see the non-existent "unstaged changes" is in gitk, where it says "Local uncommitted changes, not checked in to index"

Running git stash allows the dcommit to work for some reason:

$ 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

I have an alias to run git stash; git svn dcommit; git stash apply - but this is not the best workaround, as it causes merge errors when using actually using the stash

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一绘本一梦想 2024-09-23 01:06:10

当我写问题时,我发现了以下提交:

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

如果出现以下情况,则 dcommit 命令会失败
否则未修改的文件已
在工作目录中触及:

无法使用脏索引进行 dcommit。提交您的更改
首先,或者用“git stash”来隐藏它们。

发生这种情况是因为“git diff-index”
报告索引之间的差异
和文件系统:

:100644 100644 d00491……000000……M文件

修复方法是运行“git update-index
--refresh”位于“git diff-index”之前,如 git-rebase 中所做的那样
git-rebase--在“git”之前进行交互
差异文件”。

这会更改 dcommit 以显示列表
退出之前修改的文件。

还为“git”添加类似的测试用例
svn 变基”。

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

编辑: 之后的版本中截至 2011 年 11 月 19 日,提交仍然仅在 master 分支中:

$ git branch --contains 181264ad590ffef9d956fdd023369869c2d0a55f
* master

Edit2: 此更改现在在 git 1.7.3 中

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

As I was writing the question, I found the following commit:

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".

Can't decipher from the git log what version the change is in, but it looks like the change should be in the version after 1.7.2.2

Edit: As of Nov 19, 2011, the commit is still only in the master branch:

$ git branch --contains 181264ad590ffef9d956fdd023369869c2d0a55f
* master

Edit2: This change is now in git 1.7.3 onwards

> git tag --contains 181264ad590ffef9d956fdd023369869c2d0a55f | sort -V
v1.7.3
[...]
七秒鱼° 2024-09-23 01:06:10

当我尝试执行 git svn dcommit 时,我收到了类似的错误。

我尝试从非根 git 文件夹(其中包含 .git-subfolder)提交,并在 SVN 存储库中进行更改,但我尚未通过 git svn rebase 检索到 git 。

I received similar error when I tried to execute git svn dcommit.

I tried to commit from non-root git folder (which contains .git-subfolder) and with changes in SVN repo which I have not retrieved yet to git via git svn rebase.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文