叹气。
我喜欢Dropbox,但我不会建议将其用作“托管”Git存储库。它的同步对于单个文件文档已经足够好了,但它远远不能提供分布式/远程文件系统语义,这是安全托管Git存储库所需的。
希望你只是在Dropbox上“托管”一个裸的Git存储库。如果是这样,你应该能够从非裸(工作)存储库中拼凑出提交和引用。手动恢复现有存储库也是可能的,但你很可能最终需要从其他存储库复制对象,因此最好按照以下“高级”方式进行操作(而不是进行“低级”操作并处理从其他存储库复制对象(或复制包文件并解压其中的部分))。
首先,从一个工作目录中进行独立克隆。
git clone file://path/to/myrepo /path/to/myrepo-recovery-work
从其他工作仓库中导入引用和对象。
# If you have network access to the other repositories:
cd /path/to/myrepo-recovery-work
git remote add other1 user@machine:path/to/other/working-repo-1
git remote add other2 ssh://user@machine/path/to/other/working-repo-2
# etc.
git fetch --all
# If you do not have network access:
cd /path/to/other/working-repo-1 && # on machine with working-repo-1
git bundle create /path/to/other1.gitbundle --all HEAD
cd /path/to/other/working-repo-2 && # on machine with working-repo-2
git bundle create /path/to/other2.gitbundle --all HEAD
# etc.
# Transfer the bundle files to the machine that has "myrepo-recovery-work"
# (Dropbox is OK to copy the bundles, they are just single files),
# then on that machine:
cd /path/to/myrepo-recovery-work
git remote add other1 /path/to/transferred/other1.gitbundle
git remote add other2 /path/to/transferred/other2.gitbundle
# etc.
git fetch --all
然后,浏览您的新远程仓库中的所有分支,并确定哪些分支应指向哪些提交以重建您的中央仓库。
git log --oneline --graph --decorate --abbrev-commit --all
git branch recovered/maintenance decafbad
git branch recovered/master cafebabe
git branch recovered/development deadbeef
git branch recovered/bug-1234 8badf00d
创建并推送您恢复的分支(和标签)到一个新的裸仓库。
git init --bare /path/to/new-central-bare-repo.git # or real Git hosting service!
git remote add new /path/to/new-central-bare-repo.git
git push --tags new 'refs/heads/recovered/*:refs/heads/*'
git fsck
)你的问题实际上暗示这些问题是与远程仓库有关的。 - Cascabel