在我进行重写的机器上,简单的
git fetch
就能同步所有内容。在另一台mac机器上,
git sync
没有帮助,但是在随机删除本地的 .git /
日志和引用文件后,并发出 git pull
,历史得到了刷新。然而,在Windows机器上无论我做什么,都无法刷新项目历史记录。 尝试了以下所有方法:
-
git reset --hard HEAD
&git fetch
-
git fetch --all
-
git pull
- 等等
我按照这个教程进行了大量的历史重写: https://help.github.com/articles/changing-author-info/
Open Terminal.
Create a fresh, bare clone of your repository:
git clone --bare https://github.com/user/repo.git
cd repo.git
Copy and paste the script, replacing the following variables based on the information you gathered:
OLD_EMAIL
CORRECT_NAME
CORRECT_EMAIL
#!/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
view rawgit-author-rewrite.sh hosted with ❤ by GitHub
Press Enter to run the script.
Review the new Git history for errors.
Push the corrected history to GitHub:
git push --force --tags origin 'refs/heads/*'
Clean up the temporary clone:
cd ..
rm -rf repo.git
有没有人有大规模的Git历史重写的经验?如果有,其他团队成员需要采取哪些步骤来刷新他们的Git历史记录?
git reset --hard HEAD
只会从您当前的提交中刷新文件,如果这是重写期间丢失的提交之一,则无法帮助。相反,请执行git reset --hard origin/branchname
,将其替换为您所在的分支名称(如果需要,还要替换为远程名称)。此外,请确保您有本地存储库的备份,如果您丢失文件,我不负责任。 - Lasse V. Karlsenfetch
这样的 Git 命令可以刷新所有分支的完整历史记录吗? - sandalone