试图克隆我的整个GitHub帐户(窗口)

时间:2015-05-03 23:40:54

标签: git github github-for-windows

旧电脑上的主板被炸了。试图设置新计算机(Windows)...我无法找到如何克隆我的整个帐户....我需要。

帐户网址是:

https://github.com/MyName

然而,当我这样做时:

git clone https://github.com/MyName C:/Users/MyName/Documents/GitHub/

我得到了

>Cloning into GitHub 'C:/Users/MyName/Documents/GitHub/'
>fatal: repository 'https://github.com/MyName' not found

I learned about repos vs accounts here.

1 个答案:

答案 0 :(得分:0)

您需要使用GitHub Repos API才能列出所有回购信息:

GET /users/:username/repos

从那里你可以循环并克隆每一个。

例如,请参阅此bash script(来自Michael Field -- michfield),其中为每个回购创建一个带clone_allrepos_${usr}.sh命令的shell git clone,同时考虑{{3} }}:

usr="MyName";
url="https://api.github.com/users/${usr}/repos";
num=$(curl -sI "$url?page=1&per_page=100" | sed -nr 's/^Link:.*page=([0-9]+)&per_page=100>; rel="last".*/\1/p');
for ((i=1;i<=$num;i++)); do ( curl -s "$url?page=${i}&per_page=100" | grep "clone_url" | sed -nr 's/.*clone_url": "(.*)",/git clone \1/p' ); done >clone_allrepos_${usr}.sh
  

准备好后执行创建的.sh

 ./clone_allrepos_${usr}.sh