开发技巧iOS·葵花宝典

Github仓库迁移,替换Commit数据信息

2017-04-10  本文已影响74人  Andy矢倉

最近迁移了Github上旧的脑残账号,把仓库迁移到新账号的时候无意中发现Github提供了替换Commit的方法,由于仓库里都是自己提交的代码,索性通过Github提供的脚本把旧账号的信息全部替换到新账号,这样新账号还能装上经常Contribution的逼,保证不侧漏。

官方提供了入口:https://help.github.com/articles/changing-author-info/

Gist被DNS污染的问题,要访问还是奉劝扛上梯子为妙。

# user:github账号
# repo.git: 仓库名称
git clone --bare https://github.com/user/repo.git
cd repo.git
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="your-old-email@example.com"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="your-correct-email@example.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
    export GIT_COMMITTER_NAME="$CORRECT_NAME"
    export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
then
    export GIT_AUTHOR_NAME="$CORRECT_NAME"
    export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags

记得权限需要chmod 777才能执行写入

git push --force --tags origin 'refs/heads/*'

想我大iOS界有很多恶心的逼,最后提醒那些别有用心人,莫用这个方法去盗别人仓库。不是你的,再怎么装逼也不是你的。

上一篇 下一篇

猜你喜欢

热点阅读