# 取得 github 上所有 starred 的 repo ###### tags: `Lv.5` `github` `shell` `oneliner` 突然想要把自己 starred 的 repo 都抓回來一份(是不是早該在M$接手逃難潮之前就先做一次呢...),找了一下發現果然[有人想過](https://stackoverflow.com/questions/23329519/is-there-a-simple-way-to-clone-all-starred-repos-from-github),但裡面的方法好像都多少有些問題無法無腦用。 1. api per_page 限制在100 2. ssh_url 基本是沒權限拉的(可能要加key) 身為 oneliner 愛好者,調整了一下: ``` USER=notexist; curl "https://api.github.com/users/$USER/starred?per_page=1000&page="{1..3} |grep clone_url| grep -o 'https://[^"]*'|xargs -L1 git clone ``` 改抓 clone_url 以便 git 可以無條件 clone ,而頁數部分還沒想到如何優雅的取得並回寫 oneliner,就拉一波先吧。 而抓過一回後就要進去更新就比較簡單,一樣[有人做過](https://stackoverflow.com/questions/3497123/run-git-pull-over-all-subdirectories) ``` find . -type d -depth 1 -exec git --git-dir={}/.git --work-tree=$PWD/{} pull origin master \; ```