使用 Git SVN 追溯纠正作者? [英] Retroactively Correct Authors with Git SVN?
问题描述
我有一个我已经已经从 Subversion 克隆的存储库.我一直在以 Git 形式在这个存储库中做一些工作,我不想通过再次克隆而丢失该结构.
I have a repository which I have already cloned from Subversion. I've been doing some work in this repository in its Git form and I would hate to lose that structure by cloning again.
但是,当我最初克隆存储库时,我未能正确指定 svn.authors
属性(或语义相似的选项).
However, when I originally cloned the repository, I failed to correctly specify the svn.authors
property (or a semantically-similar option).
既然存储库是完全 Git 化的,有什么方法可以指定 SVN 作者映射吗?
Is there any way I can specify the SVN author mappings now that the repository is fully Git-ified?
最好,我想更正所有旧的提交作者,以代表 Git 作者而不是原始 SVN 用户名.
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 使用 π 指出了我脚本中的引用问题.谢谢!
edit Use π pointed out a quoting problem in my script. Thanks!
这篇关于使用 Git SVN 追溯纠正作者?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!