👻
git/gh コマンド。個人的チートシート
割と使うコマンドを集めてみた。
| cmd | desc |
|---|---|
git status |
現在の状況を表示 |
git add file-name |
変更をステージング |
git add . |
すべてをステージング |
git commit -m “msg” |
コミットにメッセージを追加 |
git push |
リモートにプッシュ |
git push —tag |
リモートにタグをプッシュ |
git pull |
リモートからフェッチしてマージ |
git fetch |
リモートからローカルoriginにデータをフェッチ |
git merge target-branch-name |
現在のブランチにターゲットブランチをマージ |
git fetch && git merge origin |
git pullのようなもの |
git switch -c “new-branch-name” |
ブランチを作成して移動 |
git switch “branch-name” |
ブランチに移動 |
git diff |
最後のコミット[1]からの現在の差分をlessで表示 |
git —no-pager diff |
git diffを全文表示(lessなし) |
git log |
コミットを一覧表示 |
git log —all —date-order —date=format:”%Y-%m-%d” —graph —format=“ <%h> %ad [%an] %C(green)%d%Creset %s” |
ログをフォーマットして表示。[2] |
git log -n 5 |
直近5件のコミットを表示 |
git tag tag-name |
gitタグを作成 |
gh auth login |
ghで操作するためにgithubの認証を行う。キーの貼り付けとブラウザ認証の2種類がある。git pushなどで権限が必要な場合に便利 |
gh release create tag file |
`githubのリリースページを作成 |
gh repo create repo-name —public |
リモートリポジトリrepo-nameをgithubにパブリックで作成 |
Discussion