[英]How to have my local repo pull from master, not a deleted branch?
我有一個本地存儲庫,最初是從分支中克隆的(使用git clone --single-branch
)。 該分支已合並到master,然后刪除。
當我嘗試使用git checkout master
切換到本地存儲庫中的git checkout master
,出現error: pathspec 'master' did not match any file(s) known to git.
我不得不做一個git checkout -b master
,然后git status
說我在分支master上。
但是,當我執行git pull
,它仍然指向已刪除的分支,因為它打印出了fatal: Couldn't find remote ref refs/heads/deleted-branch-name
。
如何刪除對已刪除分支的所有剩余引用,以便git pull
從master分支中拉出?
克隆單個分支時,您只會獲得該單個分支,而不會獲得master
。 然后,當您執行git checkout -b master
,您將簽出到正在動態創建的分支。 也就是說,您創建一個稱為master
的本地分支,然后簽出該分支。 當然,該master
分支與您的remote master
無關。 您可能已經使用git fetch origin
獲取了倉庫的所有分支。 例:
git fetch origin
git checkout -b master # creates a new branch called master
git merge origin/master # merge the master branch from the repo into yours
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.