LESSON 15分

このセクションで学ぶこと

Gitには独特の用語がたくさんあります。最初に覚えるべき基本用語を整理しましょう。


Gitの3つの場所

Gitでファイルを管理するとき、3つの「場所」を意識する必要があります。

graph LR
    subgraph LocalPC["ローカル(自分のPC)"]
        Working["作業ディレクトリ<br/>(Working)<br/>ファイルを編集"]
        Staging["ステージング<br/>(Staging)<br/>変更を準備"]
        Repo["リポジトリ<br/>(Repo)<br/>履歴に記録"]
    end

    Working -->|"add"| Staging
    Staging -->|"commit"| Repo

    style LocalPC fill:#f8fafc,stroke:#475569,stroke-width:2px,color:#1e293b
    style Working fill:#dbeafe,stroke:#2563eb,stroke-width:2px,color:#1e40af
    style Staging fill:#fef3c7,stroke:#d97706,stroke-width:2px,color:#92400e
    style Repo fill:#d1fae5,stroke:#059669,stroke-width:2px,color:#064e3b

基本用語一覧

操作に関する用語

用語読み方意味
commitコミット変更を履歴に記録すること
addアド変更をステージングに追加すること
pushプッシュローカルの変更をリモートに送ること
pullプルリモートの変更をローカルに取り込むこと
cloneクローンリモートリポジトリを丸ごとコピーすること
fetchフェッチリモートの情報だけ取得すること(マージはしない)

場所に関する用語

用語読み方意味
working directoryワーキングディレクトリ実際にファイルを編集する場所
staging areaステージングエリアコミット前の準備場所(インデックスとも呼ぶ)
repositoryリポジトリ履歴が保存される場所

状態に関する用語

用語読み方意味
trackedトラックトGitが追跡しているファイル
untrackedアントラックトGitがまだ追跡していないファイル
modifiedモディファイド変更されたが、まだステージングされていない
stagedステージドステージングに追加され、コミット待ち

コミット(commit)

一言で言うと

「この時点の状態を保存!」という操作

例え話

ゲームの「セーブポイント」のようなもの。コミットすると、その時点の状態に いつでも戻れます。

コマンド

git commit -m "変更内容の説明"

コミットに含まれる情報

commit a1b2c3d4e5f6...
Author: Taro Yamada <taro@example.com>
Date:   Mon Jan 27 10:00:00 2026 +0900

    ログイン機能を追加
  • コミットID: 変更を識別するユニークな文字列
  • Author: 誰がコミットしたか
  • Date: いつコミットしたか
  • Message: 何を変更したかの説明

ステージング(staging)

一言で言うと

「この変更をコミットに含める」と選ぶ操作

なぜ必要?

複数のファイルを変更したとき、「今回はAとBだけコミットして、Cは後で」ということができます。

例え話

スーパーの「カゴ」のようなもの。商品(変更)をカゴに入れてから、レジ(コミット)に持っていきます。

コマンド

git add ファイル名     # 特定のファイルをステージング
git add .             # すべての変更をステージング

プッシュ(push)とプル(pull)

push: ローカル → リモート

git push

自分の変更をチームに共有するときに使います。

pull: リモート → ローカル

git pull

チームメンバーの変更を取り込むときに使います。

図解

graph LR
    You["あなたのPC"]
    GitHub["GitHub"]
    Colleague["同僚のPC"]

    You -->|"push"| GitHub
    Colleague -->|"push"| GitHub
    GitHub -->|"pull"| You
    GitHub -->|"pull"| Colleague

    style You fill:#dbeafe,stroke:#2563eb,stroke-width:2px,color:#1e40af
    style GitHub fill:#fef3c7,stroke:#d97706,stroke-width:2px,color:#92400e
    style Colleague fill:#d1fae5,stroke:#059669,stroke-width:2px,color:#064e3b

クローン(clone)

一言で言うと

リモートリポジトリを丸ごとコピーする

コマンド

git clone https://github.com/someone/project.git

いつ使う?

  • 新しいプロジェクトに参加するとき
  • オープンソースのコードを手元で動かしたいとき

よく使うコマンドまとめ

# 状態確認
git status           # 現在の状態を確認

# 基本の流れ
git add ファイル名    # 変更をステージング
git commit -m "説明"  # 変更をコミット
git push             # リモートに送信
git pull             # リモートから取得

# 履歴確認
git log              # コミット履歴を表示
git diff             # 変更内容を表示

用語の関係図

graph TD
    RemoteRepo["リモートリポジトリ(GitHub)"]

    subgraph LocalBox["ローカルリポジトリ"]
        Working["Working<br/>(作業)"]
        Staging["Staging<br/>(準備)"]
        Repository["Repository<br/>(履歴)"]
    end

    RemoteRepo -->|"clone"| LocalBox
    Repository -->|"push"| RemoteRepo
    RemoteRepo -->|"pull"| Working
    Working -->|"add"| Staging
    Staging -->|"commit"| Repository

    style RemoteRepo fill:#dbeafe,stroke:#2563eb,stroke-width:2px,color:#1e40af
    style LocalBox fill:#f8fafc,stroke:#475569,stroke-width:2px,color:#1e293b
    style Working fill:#fef3c7,stroke:#d97706,color:#92400e
    style Staging fill:#fce7f3,stroke:#db2777,color:#831843
    style Repository fill:#d1fae5,stroke:#059669,color:#064e3b

まとめ

用語意味コマンド
commit変更を記録git commit
addステージングに追加git add
pushリモートに送信git push
pullリモートから取得git pull
cloneリポジトリをコピーgit clone

今日覚えるべきこと

  1. 変更は add → commit の順で記録する
  2. 共有は push / pull で行う
  3. 新規参加は clone でリポジトリをコピー

次のステップへ

Gitの基本用語は理解できましたか?

次のセクションでは、理解度チェックのクイズに挑戦します。Step 1で学んだ内容を振り返りましょう。


推定読了時間: 15分