使用Git SVN追溯正确的作者? [英] Retroactively Correct Authors with Git SVN?
问题描述
我有一个存储库,我已经从SVN克隆了。我一直在以Git的形式在这个仓库中做一些工作,我不愿意再次通过克隆来丢失这个结构。但是,当我最初克隆存储库时,我未能正确指定 svn.authors
属性(或语义相似的选项)。有没有什么办法可以指定SVN作者映射现在存储库完全Git-ified?最好是,我想纠正所有旧的提交作者来代表Git作者,而不是原始SVN用户名。 解决方案
从看到你需要清理的东西开始:
git shortlog -s
$ c $对于这些名称中的每一个,在脚本中创建一个条目,如下所示(假设您希望所有作者和提交者都是相同的):
$ b $ pre $ #!/ bin / sh
git filter-branch --env-filter'
n = $ GIT_AUTHOR_NAME
m = $ GIT_AUTHOR_EMAIL
$ b $ case $ {GIT_AUTHOR_NAME} in
user1)n =User One; m =user1@example.com;;
用户二)n =用户二; m =user2@example.com;;
esac
export GIT_AUTHOR_NAME =$ n
export GIT_AUTHOR_EMAIL =$ m
export GIT_COMMITTER_NAME =$ n
export GIT_COMMITTER_EMAIL = $ m
'
这基本上是我用于 large rewrite 最近的情况与您所描述的非常相似(除了我有大量的作者)。
编辑使用π指出脚本中存在引用问题。谢谢!
I have a repository which I have already cloned from SVN. I've been doing some work in this repository in its Git form and I would hate to lose that structure by cloning again. However, when I originally cloned the repository, I failed to correctly specify the svn.authors
property (or a semantically-similar option). Is there any way I can specify the SVN author mappings now that the repository is fully Git-ified? Preferably, I would like to correct all of the old commit authors to represent the Git author rather than the raw SVN username.
Start out by seeing what you've got to clean up:
git shortlog -s
For each one of those names, create an entry in a script that looks like this (assuming you want all the authors and committers to be the same):
#!/bin/sh
git filter-branch --env-filter '
n=$GIT_AUTHOR_NAME
m=$GIT_AUTHOR_EMAIL
case ${GIT_AUTHOR_NAME} in
user1) n="User One" ; m="user1@example.com" ;;
"User Two") n="User Two" ; m="user2@example.com" ;;
esac
export GIT_AUTHOR_NAME="$n"
export GIT_AUTHOR_EMAIL="$m"
export GIT_COMMITTER_NAME="$n"
export GIT_COMMITTER_EMAIL="$m"
'
That's basically the script I used for a large rewrite recently that was very much as you described (except I had large numbers of authors).
edit Use π pointed out a quoting problem in my script. Thanks!
这篇关于使用Git SVN追溯正确的作者?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!