Skip to main content

Git Tips

  • Overwrite local files forcefully 1
git fetch --all
git reset --hard origin/master
git pull origin master
  • Migrate repository 2
git clone --mirror <repo>
cd <repo>
git remote set-url --push origin <new repo>
git push --mirror
  • Restore local brach 3
git reflog
git checkout -b <branch> <sha>

Footnotes

  1. Git force pull to overwrite local files, Zotero

  2. Migrate Git Repository with Branches and Commit History | DataNext Solutions, Zotero

  3. git local branch 删除后如何恢复?, Zotero