Git 过滤分支不会重写所有历史记录
我正在尝试使用以下命令重写存储库的历史记录:
git filter-branch -f --env-filter '
an="$GIT_AUTHOR_NAME"
am="$GIT_AUTHOR_EMAIL"
cn="$GIT_COMMITTER_NAME"
cm="$GIT_COMMITTER_EMAIL"
if [[ "$GIT_COMMITTER_EMAIL" = jacks* ]]
then
cn="Jack Slingerland"
cm="[email protected]"
an="Jack Slingerland"
am="[email protected]"
fi
if [[ "$GIT_AUTHOR_EMAIL" = jacks* ]]
then
cn="Jack Slingerland"
cm="[email protected]"
an="Jack Slingerland"
am="[email protected]"
fi
export GIT_AUTHOR_NAME="$an"
export GIT_AUTHOR_EMAIL="$am"
export GIT_COMMITTER_NAME="$cn"
export GIT_COMMITTER_EMAIL="$cm"'
-- --all
该命令运行良好,并按指定重写作者。问题是它似乎遗漏了历史中的一些条目。我认为当分支中所做的更改被合并时就会发生这种情况,但我不确定。
注意:这是使用Git+SVN导入到Git的SVN存储库。
I'm trying to re-write a repo's history using:
git filter-branch -f --env-filter '
an="$GIT_AUTHOR_NAME"
am="$GIT_AUTHOR_EMAIL"
cn="$GIT_COMMITTER_NAME"
cm="$GIT_COMMITTER_EMAIL"
if [[ "$GIT_COMMITTER_EMAIL" = jacks* ]]
then
cn="Jack Slingerland"
cm="[email protected]"
an="Jack Slingerland"
am="[email protected]"
fi
if [[ "$GIT_AUTHOR_EMAIL" = jacks* ]]
then
cn="Jack Slingerland"
cm="[email protected]"
an="Jack Slingerland"
am="[email protected]"
fi
export GIT_AUTHOR_NAME="$an"
export GIT_AUTHOR_EMAIL="$am"
export GIT_COMMITTER_NAME="$cn"
export GIT_COMMITTER_EMAIL="$cm"'
-- --all
The command runs fine, and rewrites the author as specified. The problem is that it seems to miss some entries in the history. I think it's happening when changes made in a branch were merged in, but I'm not sure.
Note: This is an SVN repository that was imported into Git using Git+SVN.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不认为你的条件正在检查你想要什么。不应该:
是
注意:这只适用于 Bash 3.0 或更高版本。否则,我认为您需要使用 grep 或 sed 外部命令作为条件检查的一部分。
另外,我认为只有当提交者的电子邮件不是 Jack 时才需要更改提交者,反之亦然。因此,请确保删除提交者电子邮件检查中的
an
和am
分配,并对作者电子邮件检查进行类似的修复。I don't think your conditionals are checking what you want. Shouldn't:
be
Note: this will only work in Bash 3.0 or higher. Otherwise I think you'll need to use
grep
orsed
external commands as part of your conditional checks.Also, I think you will only want to change the commiter when the commiter's email isn't Jack's and vice versa for the author. So make sure you take out your
an
andam
assignments in your comitter email check and make the similar fix to your author email check.