如何使用 Git *INTO* 拉取/获取裸存储库?
我正在编写一个工具来将我的所有存储库从 Bitbucket (支持 Git 和 Mercurial)备份到我的本地计算机。
它已经适用于 Mercurial,我这样做:
- 在本地计算机上创建一个没有工作副本的新空存储库
(与bare
Git 存储库相同) - 从远程存储库拉入本地空存储库
现在我尝试使用 Git 执行相同的操作。
我已经发现我不能直接pull
到一个裸存储库,我应该使用 fetch
代替。
所以我尝试了一下:
C:\test>git fetch https://github.com/SamSaffron/dapper-dot-net.git
remote: Counting objects: 1255, done.
remote: Compressing objects: 100% (1178/1178), done.
remote: Total 1255 (delta 593), reused 717 (delta 56)
Receiving objects: 100% (1255/1255), 13.66 MiB | 706 KiB/s, done.
Resolving deltas: 100% (593/593), done.
From https://github.com/SamSaffron/dapper-dot-net
* branch HEAD -> FETCH_HEAD
显然 Git 确实获取了一些东西,但之后本地存储库是空的。
(git log
说致命:错误的默认修订版“HEAD”
)
我做错了什么?
免责声明:
我只有非常非常基本的 Git 知识(我通常使用 Mercurial)。
我正在使用 Windows,如果这很重要的话。
I'm writing a tool to backup all my repositories from Bitbucket (which supports Git and Mercurial) to my local machine.
It already works for Mercurial, where I do it like this:
- create a new empty repository without a working copy on the local machine
(the same like abare
Git repository) - pull from the remote repository into the local empty repository
Now I'm trying to do the same with Git.
I already found out that I can't directly pull
to a bare repository and that I should use fetch
instead.
So I tried it:
C:\test>git fetch https://github.com/SamSaffron/dapper-dot-net.git
remote: Counting objects: 1255, done.
remote: Compressing objects: 100% (1178/1178), done.
remote: Total 1255 (delta 593), reused 717 (delta 56)
Receiving objects: 100% (1255/1255), 13.66 MiB | 706 KiB/s, done.
Resolving deltas: 100% (593/593), done.
From https://github.com/SamSaffron/dapper-dot-net
* branch HEAD -> FETCH_HEAD
Obviously Git did fetch something, but the local repository is empty after that.
(git log
says fatal: bad default revision 'HEAD'
)
What am I doing wrong?
Disclaimer:
I have only very, very basic Git knowledge (I usually use Mercurial).
And I'm using Windows, if that matters.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
尝试
Try
要将远程存储库备份到裸存储库中,请先定期配置
,然后只需运行
备份即可。
"
),以保护星号 (*
) 不被您的 shell 解释。To backup the remote repository into your bare repository regulary configure first
and then simply run
to backup.
"
) in the above command to protect the asterix (*
) not to be interpreted from your shell.--prune
is used to also delete by now non-existent branches.我想如果你真的想备份的话。您可以尝试 $ git clone --mirror XXXX 命令。它将从存储库中获取几乎所有内容。希望它有帮助。
I think you if you really want to backup. You can try
$ git clone --mirror XXXX
command. it will get almost everything from repository. Hope it is helpful.