0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ghコマンドでgitを操作する

Posted at

はじめに

表題通り、ghコマンドでgitを操作します。

インストール~ログインまで

brewでinstallする
brew install gh

Gitのログイン
~  $ gh auth login                                               
? Where do you use GitHub? GitHub.com
? What is your preferred protocol for Git operations on this host? HTTPS
? Authenticate Git with your GitHub credentials? Yes
? How would you like to authenticate GitHub CLI? Login with a web browser

! First copy your one-time code: 07CD-XXXX
Press Enter to open https://github.com/login/device in your browser... 
✓ Authentication complete.
- gh config set -h github.com git_protocol https
✓ Configured git protocol
✓ Logged in as kouji0705

→ブラウザが起動するので、ログイン認証を実施します。
image.png

便利コマンド

PRの管理を表示する
~/develop/cli  (trunk)$ gh pr list                                                                                                                                                                                   (base) 

Showing 23 of 23 open pull requests in cli/cli

ID      TITLE                                                                                                        BRANCH                                                                         CREATED AT        
#10081  Update install_linux.md                                                                                      Tomaszek2902:patch-1                                                           about 5 hours ago
#10051  Use Windows compatible file name for downloaded attestations when running `gh attestation download`          malancas:gh-attestation-download-windows-bug                                   about 4 days ago
#10048  Fixing gh gist view prompts with no TTY                                                                      mateusmarquezini:fix/issue_10042                                               about 4 days ago
#10012  Perform all `gh attestation verify` policy options configuration in the `newEnforcementCriteria()` function  malancas:consolidate-verify-policy-options-config                              about 9 days ago
#10002  Allow argument to `gh repo set-default` to be the name of a remote                                           ADKaster:setdefault-remote                                                     about 9 days ago
#9998   Gh attestation verify options cleanup                                                                        malancas:gh-attestation-verify-options-cleanup                                 about 10 days ago
#9957   Implement git project description (`.git/description`)                                                       moritztim:description-file                                                     about 20 days ago
#9940   Rename local repo by `gh repo rename`                                                                        benebsiny:cli-9695                                                             about 23 days ago
#9934   Bring extension update logic up to par with gh update logic                                                  andyfeller/cli-cli-8183-timeout-pt2                                            about 25 days ago
#9868   feat: let user select pr to checkout                                                                         nilvng:nil/fix-2329                                                            about 1 month ago
#9847   [gh search issues] Support multiple author options                                                           Shion1305:shion/9828                                                           about 1 month ago
#9792   fix(workflow/run): check if workflow exists on the default branch to be run                                  arunsathiya:fix/9781-workflow-run-requirement-default-branch                   about 1 month ago
#9497   Fix `pr checkout`, cannot set up tracking info                                                               muzimuzhi:fix/pr-checkout-with-restricted-remote-fetch                         about 3 months ago
#9416   feat(ghinstance): allow port in host                                                                         nobe4:allow-hort-in-host                                                       about 4 months ago
#9339   fix #562 by adding a warning message when PR branch has diverged from local                                  Wires77:pr_checkout_messaging                                                  about 4 months ago
#9208   Find PRs using `@{push}`                                                                                     Frederick888:find-pr-by-rev-parse-push                                         about 6 months ago
#9083   add remote check to secret and variable commands                                                             wingleung:add-remote-check-to-secret-and-variable                              about 7 months ago
#9044   Fallback clone from user organization                                                                        maaslalani:fallback-organization                                               about 7 months ago
#9037   issue edit: avoid race conditions when editing assignees, reviewers                                          wingleung:issue-edit-avoid-race-conditions-when-editing-assignees,-reviewers-  about 7 months ago
#8826   feat: implement gh `pr revert`                                                                               lucasmelin:lucasmelin/add-pr-revert-command                                    about 9 months ago
#8718   feat: add `gh deployment` commands                                                                           sjparkinson:add-deployment                                                     about 9 months ago
#7743   Use native keychain bindings if possible                                                                     YorikSar:native-keyring                                                        about 1 year ago
#7322   feat(pr): Add cleanup subcommand to delete merged local branches                                             elldritch:feat/pr-cleanup                                                      about 1 year ago
~/develop/cli  (trunk)$                                                                                                                                                                 
PRをチェックアウトする
~/develop/cli  (trunk)$ gh pr checkout 10081                                                                                                                                                                         (base) 
remote: Enumerating objects: 1, done.
remote: Counting objects: 100% (1/1), done.
remote: Total 1 (delta 0), reused 1 (delta 0), pack-reused 0 (from 0)
Unpacking objects: 100% (1/1), 842 bytes | 280.00 KiB/s, done.
From https://github.com/cli/cli
 * [new ref]           refs/pull/10081/head -> patch-1
Switched to branch 'patch-1'
ブラウザで現在のgitを開く
gh browse
0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?