git config --global core.quotepath false // 解決終端中文亂碼
git push --force-with-lease // 比 force 安全的強(qiáng)行推送
問題
fatal: pathspec '.DS_Store' did not match any files
解決辦法
git filter-branch --force --index-filter 'git rm -r --cached --ignore-unmatch .DS_Store' --prune-empty --tag-name-filter cat -- --all
git push -f origin master
參考于: https://stackoverflow.com/questions/25458306/git-rm-fatal-pathspec-did-not-match-any-files/25458504
問題:
修改已經(jīng)提交過的 author 的 name 和 email
解決辦法:
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
git push --force --tags origin 'refs/heads/*'
參考于:https://help.github.com/en/articles/changing-author-info