Git 小記

git config --global core.quotepath false  // 解決終端中文亂碼
git push --force-with-lease // 比 force 安全的強行推送

問題

fatal: pathspec '.DS_Store' did not match any files

解決辦法

  1. git filter-branch --force --index-filter 'git rm -r --cached --ignore-unmatch .DS_Store' --prune-empty --tag-name-filter cat -- --all
  2. 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

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 1、Git下載與安裝 https://git-scm.com 選擇對應(yīng)macOS系統(tǒng)的版本進行安裝; 2、Git初...
    燈花微涼閱讀 405評論 0 5
  • 記錄Git常用的一些操作 初始化倉庫 git init 添加文件 git add filename 單個文件git...
    Tiny_z閱讀 186評論 0 0
  • error:create branch Fatal: Not a gitflow-enabled repo yet...
    osbornZ閱讀 305評論 0 0
  • 前言:最初用git時總結(jié)copy的。 clone代碼: 換行符 中文亂碼 常規(guī)操作: 添加到本地庫 拉來其他人的更...
    清晨起床敲代碼閱讀 320評論 0 0
  • 1、安裝sass01、npm install --save-dev sass-loader//sass-loade...
    丁小凱_eafe閱讀 2,710評論 0 0

友情鏈接更多精彩內(nèi)容