git svn fetch
命令后编辑了一个版本的提交信息(就像这个SO问题中所述)。那么,我该如何更正我的Git克隆以拥有正确的提交消息?我原本期望通过
git svn reset
和git svn fetch
来重新获取此提交并更新内容,从而只需要修复我的本地分支即可。但实际上它似乎并没有做任何事情;git svn fetch
未重新获取我重置的提交。(是的,我认为更改提交消息是不明智的,但我无法控制。)
更新:我尝试了sleske建议的过程(实际上,在提问之前我已经尝试过,但我刚刚再次尝试了一下),但没有成功。我得到的输出如下:
me_and@centos ~/code ((358a2dd...)) Fri 16 Jan 15:31:27
$ git svn reset -p 55102
r55094 = 25d126219f7eeddfc7d0842704c7efcc0443dd70 (refs/remotes/origin/branchname)
me_and@centos ~/code ((358a2dd...)) Fri 16 Jan 15:33:06
$ git svn fetch
me_and@centos ~/code ((358a2dd...)) Fri 16 Jan 15:33:08
$
git svn fetch
命令没有输出(或者只有在我上次运行它之后进行了提交,但是它只是获取新的提交,而不是重新获取旧的提交),特别地,没有像sleske示例中的rereading
消息。
如果相关的话,我正在使用Git v2.0.4。
更新2:下面是略加删减的.git/config
:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[svn-remote "svn"]
url = http://server/repos/repo
fetch = trunk:refs/remotes/origin/trunk
branches = branches/*:refs/remotes/origin/*
tags = tags/v10/*:refs/remotes/origin/tags/*
tags = tags/v11/*:refs/remotes/origin/tags/*
tags = tags/v12/*:refs/remotes/origin/tags/*
tags = tags/v13/*:refs/remotes/origin/tags/*
我不会发布完整的git branch -avv
输出,因为它非常冗长。但这是最有趣的部分,所以我将列出我所做的一切:
I had a checkout of a branch other than the branch with the error. Running
git svn reset
made no difference:remotes/origin/branchname
continued to point at a more recent commit. Unsurprisingly,git svn fetch
did nothing.I checked out
remotes/origin/branchname
and rangit svn reset
again. This worked:remotes/origin/branchname
pointed at the parent of the duff commit.I ran
git svn fetch
. This did absolutely nothing: no commits were fetched andremotes/origin/branchname
didn't move.I created a couple of dummy commits on that branch in the Subversion repository (one added an empty file, the next deleted it again), then ran
git svn fetch again
.Here's where it gets really odd: the duff commit wasn't refetched. Instead, the fetch started at the commit where I added the dummy file, reported an "Index mismatch" in the process.Running
git show
on the commit that added the dummy file shows it with all the diffs between the commit I reset to and the dummy commit.Now, running
git log --graph --decorate --pretty=oneline --abbrev-commit HEAD origin/branchname
looks like this:* 7b12bbc (origin/branchname) Remove dummy file * 730c2ab Add dummy file # But `git show 730c2ab` includes the diffs between b89af06 and 93920f9 as well | * 93920f9 (HEAD) Uninteresting commit | * 91c7163 Uninteresting commit | * ce51022 Commit with the changed commit message |/ * b89af06 Uninteresting commit
Note that, other than
HEAD
, there is now nothing pointing to some of the commits on this branch.
我越来越认为,至少其中一些行为只是git svn
中的一个bug。毫无疑问,我在上面第4点看到的情况根本不应该发生,至少按照我的理解是这样。
.git/config
文件,并根据git branch -avv
的输出做了一些调查。这非常奇怪。 - me_andgit svn
中的一个错误。恐怕为了获得更多帮助,您需要提供可重现的测试用例。您可以尝试编写一个脚本,创建一个本地SVN存储库,然后通过git svn
检出它。如果您使用相同的存储库布局和选项,并创建结构相似的提交,则可能可以重现该问题。 - sleske