如果我有 200 次提交,我在git config --global user.email和中推送了錯誤的作者資訊git config --global user.name。之后如何在命令中更改這些提交,而不必逐個檢查?
所有提交都來自同一作者,并且一些提交是在不同作者之間。那么是否可以遍歷每個提交的 FROM 和 TO 提交并發送git push --force-with-lease命令來更新主分支歷史記錄中的所有這些?
任何想法?
uj5u.com熱心網友回復:
如果它們在一條直線上,你可以用一點 bash-fu 把它拉下來:
git checkout first-commit-to-adjust~ # careful with the pig-tail... it has to be there
git log --pretty=%h --reverse HEAD..last-one-to-adjust | while read commit; do
git cherry-pick $commit
# here we need a check for the author name
if [ "$( git show --summary --pretty=%an --quiet )" == "misnamed fulanito de tal" ]; then
# yep, it's me
git commit --amend --no-edit --reset-author
fi
done
如果您只想設定作者姓名/電子郵件(不修改作者日期),我認為您必須設定環境變數的值,GIT_AUTHOR_NAME然后GIT_AUTHOR_EMAIL發出git commit --amend --no-edit命令。概念不會改變......如果你想控制更多的東西,那么你可以使用更多的環境變數。檢查git help commit。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/528627.html
標籤:混帐
上一篇:GIT替代櫻桃采摘
