[英]How do I pull/fetch with Git *INTO* a bare repository?
我正在編寫一個工具來將我的所有存儲庫從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
表示fatal: bad default revision 'HEAD'
)
我究竟做錯了什么?
免責聲明:
我只有非常非常基本的Git知識(我通常使用Mercurial)。
我正在使用Windows,如果這很重要的話。
嘗試
git fetch https://github.com/SamSaffron/dapper-dot-net.git master:master
要先將遠程存儲庫備份到裸存儲庫中,請先進行配置
git config remote.origin.url https://github.com/SamSaffron/dapper-dot-net.git
git config remote.origin.fetch "+*:*"
然后簡單地運行
git fetch --prune
備份。
"
)以保護星號( *
)不被shell解釋。 --prune
也用於刪除現在不存在的分支。 如果你真的想要備份,我想你。 您可以嘗試$ git clone --mirror XXXX
命令。 它幾乎可以從存儲庫獲得所有東西。 希望它有所幫助。
$ git fetch https://github.com/SamSaffron/dapper-dot-net.git +refs/heads/*:refs/heads/* --prune
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.