gpt4 book ai didi

git svn dcommit 总是以 "Cannot dcommit with a dirty index."失败

转载 作者:行者123 更新时间:2023-12-04 06:47:14 25 4
gpt4 key购买 nike

$ 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 ,它说“本地未提交的更改,未 checkin 索引”

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

最佳答案

在我写这个问题时,我发现了以下提交:

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



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

编辑:截至 2011 年 11 月 19 日,提交仍仅在 master 分支中:
$ git branch --contains 181264ad590ffef9d956fdd023369869c2d0a55f
* master

编辑 2:此更改现在在 git 1.7.3 之后
> git tag --contains 181264ad590ffef9d956fdd023369869c2d0a55f | sort -V
v1.7.3
[...]

关于git svn dcommit 总是以 "Cannot dcommit with a dirty index."失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3572074/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com