因此,remotes/origin/master在master之前。當我發布git status時,我得到:
在分支 master
你的分支落后于'origin/master'1次提交,可以快進。
(使用 "git pull "來更新你的本地分支)
然而,我并不想將master移動或快進到remote/origin/master。相反,我希望remotes/origin/master向后移動或倒退到master當前所在的位置。所有的Local uncommitted changes, not checked in to index已經被備份到其他地方,所以在將remotes/origin/master移回master后,如果需要的話,我可以重新創建這些更改。目前在remotes/origin/master中的所有更改都是沒有用的,可以被丟棄。
我嘗試了以下方法:
git branch -d babe82a3bb3efb71e6fdff38e40ec08fe691e5d6,試圖實作remotes/origin/master的這個回退。這就出現了錯誤:
error: branch 'babe82a3bb3efb71e6fdff38e40ec08fe691e5d6' not found.
然后我試著說:
git branch -d remotes/origin/master,結果出現錯誤:
error: branch 'remotes/origin/master' not found.
有什么方法可以做到這一點嗎?
uj5u.com熱心網友回復:
git branch -d remotes/origin/master失敗的原因很簡單:它不是一個branch。 它是一個遠程跟蹤的名字,而不是一個分支的名字。 它通常被顯示為origin/master。Git對于從refs/heads/master這樣的名字中洗掉多少是不一致的,后者成為master,而refs/remotes/origin/master則成為origin/master或remotes/origin/master,這取決于Git是否覺得要剝離一個組件--refs/或者兩個,refs/remotes/。
你的Git--你的軟體,在你的倉庫中作業--根據你的Git從其他Git那里得到的東西來創建或更新遠程跟蹤名稱:在某個other倉庫中作業的某個版本的Git軟體。 那個other 倉庫有分支名,可以找到提交。 當你把你的 Git 連接到他們的 Git 時,你的 Git 會從他們那里獲得你沒有的任何提交,然后創建或更新你的遠程跟蹤名稱,以記住他們的 分支 名稱的位置。
因此,這意味著他們名為master的分支確定了提交babe82a3bb3efb71e6fdff38e40ec08fe691e5d6。 你自己的 Git 倉庫有這個提交,因為你是從他們的 Git 倉庫得到的;你的 Git 使用 origin/master 的名字找到它,這是將 master(他們的 branch 名稱)改為 origin/master(你的遠程跟蹤名稱)產生的。
如果你認為他們的 Git 倉庫應該將他們的分支名master向后移一步,以便忘記babe82a3bb3efb71e6fdff38e40ec08fe691e5d6。而使用你自己的master指定的提交,你可以使用強制git push操作來命令他們--他們的倉庫上的Git軟體--這樣做。 他們的 Git 是否會服從你的 Git 的命令,取決于他們。 請注意,他們的提交現在可能已經在數以百萬計的其他克隆中了(這取決于他們的Git 倉庫有多受歡迎)。 如果它只在他們的倉庫中,并且你有權限像這樣用git push --force或git push --force-with-lease"倒退 "他們的分支,你就會沒事。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/308289.html
標籤:

