如何从备份恢复所有远程分支(git bundle)。
Backup:
$ git bundle create /tmp/dp --all
$ git bundle list-heads /tmp/dp | head -n5
f37c9fc7f0ce121568f42fb01390b1862c67f308 refs/heads/master
f37c9fc7f0ce121568f42fb01390b1862c67f308 refs/heads/show
9aabc2a4fb18181fee6d0e7e03170a976b6ed49b refs/remotes/origin/NewLayers
aef1fc8a416413ee5b7f4370f255ab654b3407ee refs/remotes/origin/elevator
bc4c78f94a67857fbd7210ecc5ebcd80ec736b1a refs/remotes/origin/elevator_1
$ git bundle verify /tmp/dp | head -n1
/tmp/dp is okay
The bundle contains 65 refs
Restore:
$ git clone /tmp/dp dp
Cloning into dp...
$ cd dp
$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/show
我尝试抓取和拉动,但没有帮助。
我还尝试使用“--mirror”克隆以创建裸存储库,然后从中克隆,但结果是相同的。
问题是,在克隆时,不会跟踪远程存储库的远程分支(并且远程存储库的本地分支将作为远程跟踪分支进行跟踪)。你没有在你的问题中说,但我猜用创建的(裸)存储库--mirror
包括远程跟踪分支。
所以正确的做法是:
git clone --mirror /tmp/dp
mkdir dp
mv dp.git dp/.git
cd dp
git config core.bare false
git reset --hard
(即使用 --mirror 克隆并撤消隐含的 --bare。)
不漂亮但有效。或者使用 git-init 创建一个新的空存储库,并使用一行将 /tmp/dp 定义为远程
fetch = +refs/*:refs/*
而不是正常的
fetch = +refs/heads/*:refs/remotes/remotename/*
并从中获取。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)