2020年11月6日 星期五

git bare repo 更新單一分支

 最近為了給某個 minor 出來的 git server 端加上另一個遠端的分支,碰上不少麻煩

最初

git remote add newRemote url

然後

git fetch newRemote

 把新遠端的東西抓下來,但這個遠端的東西只有這個 bare repo 自己知道,沒辦法提供給下游拉。

在 git branch 下面找半天,不論怎麼新建 branch 去追蹤新遠端上的分支都給我跳 fatal

雖然後來發現

git branch -t newBranch newRemote/newBranch

即使跳了 fatal: not tracking: ambiguous information for ref 之類的東西,但查一下 log 會發現根本就成功了

不過保險起見,後來都在 config 中加上了

[branch "newBranch"]
        remote = newRemote
        merge = refs/heads/newBranch

接著用

git fetch newRemote newBranch:newBranch

來更新這個 branch

沒有留言:

張貼留言