ちゃなべの備忘録

ほぼ備忘録です。

Githubのリモートレポジトリをローカルから作る【備忘録】

はじめに

毎回Githubのサイトでリモートレポジトリを作ってたけど、そろそろだるい。。

なんかやり方ないかな?と思ったらあったから設定する

設定

まずGitHub CLIをinstallする

cli.github.com

$ brew install gh

そしたら、新しいレポジトリをlocalで作って、それをリモートレポジトリに反映してみよう。

# GitHubCLIにログイン&権限を与える
$ gh auth login
? What account do you want to log into? GitHub.com
? What is your preferred protocol for Git operations? HTTPS
? Authenticate Git with your GitHub credentials? Yes
? How would you like to authenticate GitHub CLI? Paste an authentication token
Tip: you can generate a Personal Access Token here https://github.com/settings/tokens
The minimum required scopes are 'repo', 'read:org', 'workflow'.
? Paste your authentication token: ****************************************
- gh config set -h github.com git_protocol https
✓ Configured git protocol
✓ Logged in as ayumu-1212

# GitHubのリモートレポジトリ作成
$ gh repo create manual-oidc --public

# いま作ったレポジトリをclone
$ gh repo clone manual-oidc

$ cd manual-oidc

$ git commit --allow-empty -m ":tada: first commit"

$ git push origin main

さぁこれでどうだ?

おおーーー!できた。今後が楽だな。