最初の PR はサイトを開かなくていい

最初の PR の証拠は gh が印字する URL。Compare は不要。

ブランチは push したのに、GitHub で Compare を押さないと PR にならない?そのタブは不要。 gh pr create は成功時に pull URL を出す。それが最初の PR。図を共有するなら 今すぐ開始。

GitHub remote があり、push か fork ができ、URL が印字されたら止める。検索語は gh 導入、auth login、ターミナルで最初の PR

ghauth logingh pr create
gh pr createURL on stdout
--webopens the tab
cli.github.commanual

まず PATH に gh

  1. 1
    macOS

    Homebrew:brew install gh。続けて gh --version。

  2. 2
    Windows

    winget install --id GitHub.cli。新しい端末で版を確認。

  3. 3
    Linux

    cli.github.com の公式 apt/dnf を足してから gh を入れる。古いディストロパッケージだけに頼らない。

  4. 4
    バイナリ確認

    which gh と gh --version。無ければ PATH。

gh auth login は身分だけ

既定はブラウザ OAuth。hostname は github.com。--hostname で Enterprise。ヘッドレスは --with-token で classic PAT を標準入力から(マニュアルの最小スコープ:repo、read:org、gist)。

gh auth login
gh auth status
# headless classic PAT:
# gh auth login --with-token < mytoken.txt

最初の PR を端末で切る

ブランチ、commit、head を remote へ。未 push なら gh pr create が行き先を聞く。--title と --body でエディタを飛ばす。成功行は https://github.com/…/pull/N。

git checkout -b fix-docs
git add .
git commit -m "Fix docs"
git push -u origin fix-docs
gh pr create --title "Fix docs" --body "What changed and why."
# printed: https://github.com/owner/repo/pull/1
gh pr view

止まるのは権限でありタブではない

push できなければ fork

マニュアル:現在ブランチが remote に足りないと確認が出る。上流に push できないと、デフォルトブランチだけの fork を作れる。--head で自動 fork/push を飛ばせる。

トークンを git に入れない

PAT はファイルか環境変数。commit しない。ログアウトは gh auth logout。

Compare は Web の近道。gh が出す /pull/N が PR。

PR 文と図を揃えるなら同じページへ: ガイド · hereink のルーム

github.com は必須か?

PR 作成には不要。成功時に URL が出る。--web だけが作成ページを開く。auth login の既定は OAuth 用にブラウザを開くことがある。それはログイン。

既存の git clone と衝突するか?

しない。GitHub remote があればよい。

リポジトリが無いと言われる

Git リポジトリ内で、origin が GitHub であること。または -R owner/repo。

下書きは?

--draft。行き先は --base。確認は gh pr view。

今すぐ開始