Git コマンド大全(git-master)
このページは git の主要コマンドを、git help -a の分類に沿って
中級者向けに整理したものです。
使い方の前提
Section titled “使い方の前提”- porcelain: 日常運用で直接使う高水準コマンド
- plumbing: 内部処理向けの低水準コマンド
- ancillary / interaction: 補助・連携用途のコマンド
conflicts: 競合ファイル一覧を抽出するエイリアスcurrent-hash: 現在コミットの短縮 SHA を表示current-hash-long: 現在コミットの完全 SHA を表示lg: グラフ付きログを見やすく表示rlog: reflog を日時付きで確認
Main porcelain commands
Section titled “Main porcelain commands”add: 変更を index に追加am: メール形式のパッチを適用archive: 指定ツリーからアーカイブ生成bisect: 二分探索で不具合混入コミットを特定branch: ブランチ一覧・作成・削除bundle: オブジェクトと参照を 1 ファイルで搬送checkout: ブランチ切替やファイル復元(旧来)cherry-pick: 既存コミットを現在ブランチへ適用citool:git commitの GUI フロントエンドclean: 追跡外ファイルを削除clone: リポジトリを新規取得commit: index の内容を履歴へ記録describe: 到達可能な直近タグでコミットを説明diff: 差分表示(作業ツリー・index・コミット間)fetch: リモートからオブジェクトと参照を取得format-patch: メール送信用パッチ列を生成gc: 不要オブジェクト回収と最適化grep: Git 管理下ファイルへパターン検索gui: Git のポータブル GUI 起動init: 新規リポジトリ作成log: コミット履歴表示maintenance: メンテナンス処理を実行merge: 履歴を統合mv: ファイル移動・改名(index 追従)notes: オブジェクト注釈を追加・参照pull: fetch + merge/rebase を実行push: ローカル参照をリモートへ反映range-diff: 2 つのコミット範囲差分を比較rebase: 変更を新しい基点へ載せ替えreset: HEAD・index・作業ツリーを指定状態へ戻すrestore: index/作業ツリーの内容を復元revert: 打ち消しコミットを新規作成rm: index と作業ツリーから削除shortlog: 履歴を作者単位で要約show: オブジェクト詳細表示sparse-checkout: スパースチェックアウト設定stash: 未コミット変更を退避・復元status: 作業ツリー状態確認submodule: サブモジュール管理subtree: サブツリー取り込み・分離switch: ブランチ切替専用コマンドtag: タグ作成・一覧・削除・検証worktree: 複数作業ツリー管理
Ancillary manipulator commands
Section titled “Ancillary manipulator commands”config: Git 設定の取得・更新fast-export: 履歴を高速エクスポートfast-import: fast-import 形式を取り込みfilter-branch: 履歴書き換え(古い手法)mergetool: 外部マージツールで競合解消pack-refs: refs を圧縮して効率化prune: 到達不能オブジェクトを削除reflog: 参照更新履歴を管理remote: リモート定義を管理repack: pack ファイル再構築replace: オブジェクト置換参照を管理
Ancillary interrogator commands
Section titled “Ancillary interrogator commands”blame: 行ごとの最終更新コミットと作者を追跡bugreport: バグ報告用の環境情報収集count-objects: 非 pack オブジェクト数と容量を確認verify-commit: コミット署名検証verify-tag: タグ署名検証version: Git バージョン表示whatchanged: 差分付き履歴表示(log系の旧コマンド)
Interaction commands
Section titled “Interaction commands”archimport: Arch リポジトリ取り込みcvsexportcommit: 単一コミットを CVS へ書き出しcvsimport: CVS リポジトリを Git へ取り込みcvsserver: CVS 互換サーバを Git 上で提供imap-send: パッチ群を IMAP フォルダへ送信quiltimport: quilt パッチセット適用request-pull: 取り込み依頼用サマリー生成send-email: パッチ群をメール送信svn: Subversion との双方向連携
Plumbing manipulator commands
Section titled “Plumbing manipulator commands”apply: パッチをファイル/index へ適用checkout-index: index から作業ツリーへ展開commit-graph: commit-graph ファイル作成・検証commit-tree: ツリーから commit オブジェクト作成hash-object: オブジェクト ID 計算と blob 作成index-pack: pack インデックス作成merge-file: 3-way ファイルマージmerge-index: マージ対象ファイルへ低水準マージ実行mktag: 検証付きで tag オブジェクト作成mktree:ls-tree形式テキストから tree 作成multi-pack-index: MIDX 作成・検証pack-objects: オブジェクトを pack 化prune-packed: pack 済み重複オブジェクト削除read-tree: tree 情報を index へ読み込みsymbolic-ref: シンボリック参照の読取・更新unpack-objects: pack からオブジェクト展開update-index: 作業ツリー内容を index へ登録update-ref: 参照が指すオブジェクト名を安全更新write-tree: index から tree オブジェクト生成
Plumbing interrogator commands
Section titled “Plumbing interrogator commands”cat-file: オブジェクト内容・型情報を表示cherry: upstream 未取り込みコミット検出diff-files: 作業ツリーと index を比較diff-index: index とリポジトリの blob/mode 比較diff-tree: 2 つの tree の差分比較for-each-ref: 各 ref 情報を列挙for-each-repo: リポジトリ群へ同一コマンドを実行get-tar-commit-id:git archivetar から commit ID 抽出ls-files: index / 作業ツリーのファイル情報表示ls-remote: リモート参照一覧表示ls-tree: tree オブジェクト内容表示merge-base: 最良共通祖先を探索name-rev: リビジョンへ人間向け名前を付与pack-redundant: 重複 pack 検出rev-list: コミット列挙rev-parse: 引数解釈とリビジョン解決show-index: pack インデックス表示show-ref: ローカル参照一覧表示unpack-file: blob 内容を一時ファイルへ展開var: Git 論理変数表示verify-pack: pack ファイル整合性検証
Plumbing sync commands
Section titled “Plumbing sync commands”daemon: シンプルな Git サーバ起動fetch-pack: リモートから不足オブジェクト受信http-backend: Git over HTTP サーバ側実装send-pack: Git プロトコルでオブジェクト送信update-server-info: dumb サーバ向け補助情報更新
Plumbing sync helper commands
Section titled “Plumbing sync helper commands”http-fetch: HTTP 経由で取得http-push: HTTP/DAV 経由で pushparse-remote: リモートアクセス引数解析補助receive-pack: push 受信側処理shell: Git 専用制限シェルupload-archive:git archive応答upload-pack: fetch 用 pack 送信
Plumbing internal helper commands
Section titled “Plumbing internal helper commands”check-attr: gitattributes 情報表示check-ignore: gitignore 判定デバッグcheck-mailmap: mailmap 正規化結果を表示check-ref-format: 参照名フォーマット検証column: 出力を列整形fmt-merge-msg: マージコミットメッセージ生成mailinfo: メールからパッチ・作者情報抽出mailsplit: mbox を複数ファイルへ分割merge-one-file:merge-index用標準ヘルパーpatch-id: パッチの一意 ID 算出stripspace: 空行・空白整形
学習順のおすすめ
Section titled “学習順のおすすめ”status→add→commit→log→diffbranch/switch/merge/rebasefetch/pull/push/remotereflog/reset/restore/revert- 必要時に plumbing を参照