LoginSignup
2
6

More than 5 years have passed since last update.

自分のGitHubの全レポジトリを取得してghqで管理する

Posted at

さっと自分のレポジトリを取得してghqで管理する方法です。(macOS)

準備

ghqの他にjqを使います。
インストールしてない場合はbrewでインストール

$ brew install jq

レポジトリの取得

curlを使ってレポジトリの取得を行います。
なおprivateなレポジトリの場合は、認証挟む必要があります。

your_nameを適宜、自分のアカウント名に書き換えてください。
また、今回は、100個のレポジトリかつ更新順に取得しています。
パラメータを変えることでいい感じに調整してください。
パラメータは以下のリンクを参照してください。

GitHub API v3 | GitHub Developer Guide

$ curl 'https://api.github.com/users/${your_name}/repos?per_page=100&sort=updated' | jq -r '.[] | .full_name' > repos.txt

確認します。
jq -rを付けないと要素がダブルコーテーションで囲まれるので注意です。

$ cat repos.txt
akameco/PixivDeck
akameco/dotfiles
akameco/yamada
akameco/python-bot-sample
akameco/pixiv-app-api
akameco/SSConnectAPI
akameco/NarouTime
akameco/QiitaX
.
.
.

ghqを使った取り込み

これをghq importを使って読み込みます。
すでにある場合はスキップされます。

$ ghq import < repos.txt
    exists /Users/akameco/src/github.com/akameco/PixivDeck
    exists /Users/akameco/src/github.com/akameco/dotfiles
    exists /Users/akameco/src/github.com/akameco/yamada
        ...

以上で完了です。

2
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
6