Git結構:
1. Local repo:
(1) main
(2) test_branch
2. Remote repo:
(1) main
(2) test_branch
由于某些原因,本地repo中test_branch中的一些內容亂了,所以想把遠程repo中的test_branch拉到本地repo中的test_branch中,恢復原來的結構。
嘗試:
git checkout test_branch
git pull origin test_branch
但它沒有用。
還挖掘其他執行緒:
Git:如何強制“git pull”覆寫本地檔案?
嘗試:
git fetch --all
git branch backup-test_branch
git reset --hard origin/test_branch
但它也沒有奏效。
任何建議表示贊賞。
uj5u.com熱心網友回復:
您可以隨時洗掉本地分支并從遠程恢復,請嘗試以下操作:
git checkout main
git branch -D test_branch
git checkout test_branch
為了解釋它在做什么,它將當前分支更改為main,洗掉 的本地副本,test_branch然后更改回test_branch分支,但現在與遠程分支同步。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/322642.html
