1. 推送冲突
1 2 3 4 5 6 7
| ! [rejected] main -> main (non-fast-forward)
git fetch origin git rebase origin/main git push -f
|
2. 拉取失败
1 2 3 4 5
| fatal: refusing to merge unrelated histories
git pull origin main --allow-unrelated-histories
|
3. 分支混乱
1 2 3
| git fetch --all git reset --hard origin/main
|
4. 文件未跟踪
1 2 3 4 5
| git clean -fd
git checkout -- .
|
5. 认证问题
1 2 3 4
| git config --global credential.helper cache
git config --global credential.helper 'cache --timeout=3600'
|
6. 大文件提交
1 2 3 4
| java -jar bfg.jar --delete-files *.psd git reflog expire --expire=now --all git gc --prune=now --aggressive
|
提示:使用 git reflog 可查看所有历史操作记录,用于恢复误操作