バージョン確認
$ git --version
リポジトリ作成
$ git init
ファイルをステージング(ファイル名指定)
$ git add FILE_NAME
ファイルをステージング(カレントディレクトリ)
$ git add .
コミット
$ git commit -m "MESSAGE"
直前のコミットメッセージ修正
$ git commit --amend -m "MESSAGE"
プッシュ
$ git push
クローン(SSH)
$ git clone git@github.com:USER_NAME/REPOSITORY_NAME.git
クローン(HTTPS)
$ git clone https://github.com/USER_NAME/REPOSITORY_NAME.git
ローカルブランチ確認
$ git branch
リモートブランチ確認
$ git branch -r
ブランチ確認(ローカル+リモート)
$ git branch -a
マージ確認
$ git branch --merged
ブランチ作成
$ git branch BRANCH_NAME
$ git branch BRANCH_NAME COMMIT_ID
ブランチ名変更
$ git branch -m BRANCH_NAME
ブランチ移動
$ git switch BRANCH_NAME
ブランチの作成と移動
$ git switch -c BRANCH_NAME
$ git switch -c BRANCH_NAME COMMIT_ID
(マージ済)ブランチ削除
$ git branch -d BRANCH_NAME
(未マージ)ブランチ削除
$ git branch -D BRANCH_NAME
フェッチ
$ git fetch REMOTE_NAME BRANCH_NAME
マージ
$ git merge BRANCH_NAME
プル
$ git pull REMOTE_NAME BRANCH_NAME
チェリーピック
$ git cherry-pick COMMIT_ID
変更取消(ステージング前)
$ git restore FILE_NAME
$ git restore .
変更取消(ステージング後)
$ git reset
リポジトリ状態確認
$ git status
差分確認
$ git diff
コミットログ確認
$ git log --graph --all --oneline
作業履歴確認
$ git reflog
コミット確認
$ git show
$ git show --oneline
$ git show BRANCH_NAME
$ git show COMMIT_ID
$ git show COMMIT_ID:FILE_NAME
ファイル削除
$ git rm FILE_NAME
ディレクトリ削除
$ git rm -r DIRECTORY_NAME
ファイル名変更・ディレクトリ名変更
$ git mv FILE_NAME FILE_NAME_RENAMED
$ git mv DIRECTORY_NAME DIRECTORY_NAME_RENAMED
参考
Git - Reference
Basic Git commands | Bitbucket Data Center 9.2 | Atlassian Documentation
GitHub - joshnh/Git-Commands: A list of commonly used Git commands
A list of commonly used Git commands. Contribute to joshnh/Git-Commands development by creating an account on GitHub.