[英]How do I pull/fetch with Git *INTO* a bare repository?
I'm writing a tool to backup all my repositories from Bitbucket (which supports Git and Mercurial) to my local machine. 我正在编写一个工具来将我的所有存储库从Bitbucket (支持Git和Mercurial)备份到我的本地计算机。
It already works for Mercurial, where I do it like this: 它已经适用于Mercurial,我这样做:
bare
Git repository) bare
Git存储库) Now I'm trying to do the same with Git. 现在我正在尝试用Git做同样的事情。
I already found out that I can't directly pull
to a bare repository and that I should use fetch
instead. 我已经发现我不能直接
pull
一个裸存储库,而是我应该使用fetch
。
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 确实取了一些东西,但之后本地存储库是空的。
( git log
says fatal: bad default revision 'HEAD'
) (
git log
表示fatal: bad default revision 'HEAD'
)
What am I doing wrong? 我究竟做错了什么?
Disclaimer: 免责声明:
I have only very, very basic Git knowledge (I usually use Mercurial). 我只有非常非常基本的Git知识(我通常使用Mercurial)。
And I'm using Windows, if that matters. 我正在使用Windows,如果这很重要的话。
尝试
git fetch https://github.com/SamSaffron/dapper-dot-net.git master:master
To backup the remote repository into your bare repository regulary configure first 要先将远程存储库备份到裸存储库中,请先进行配置
git config remote.origin.url https://github.com/SamSaffron/dapper-dot-net.git
git config remote.origin.fetch "+*:*"
and then simply run 然后简单地运行
git fetch --prune
to backup. 备份。
"
) in the above command to protect the asterix ( *
) not to be interpreted from your shell. "
)以保护星号( *
)不被shell解释。 --prune
is used to also delete by now non-existent branches. --prune
也用于删除现在不存在的分支。 I think you if you really want to backup. 如果你真的想要备份,我想你。 You can try
$ git clone --mirror XXXX
command. 您可以尝试
$ git clone --mirror XXXX
命令。 it will get almost everything from repository. 它几乎可以从存储库获得所有东西。 Hope it is helpful.
希望它有所帮助。
$ git fetch https://github.com/SamSaffron/dapper-dot-net.git +refs/heads/*:refs/heads/* --prune
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.