Git入門:インストールと初期設定を画面付きで解説【2026年版】

Tech Trends AI
- 4 minutes read - 680 wordsGit入門:インストールと初期設定を画面付きで解説【2026年版】
はじめに
プログラミングを始めたばかりの方にとって、Gitは必須のツールです。Gitを使うことで、コードの変更履歴を管理し、他の開発者と協力してプロジェクトを進めることができます。
この記事では、Git初心者向けに以下の内容を画面付きで説明します:
- Windows・Mac・LinuxでのGitインストール方法
- 基本的な初期設定
- 動作確認方法
Gitとは?
Gitは、分散型バージョン管理システムです。以下のような機能を提供します:
- コードの変更履歴管理:いつ、誰が、何を変更したかを記録
- ブランチ機能:複数の開発ラインを並行管理
- リモートリポジトリ連携:GitHubなどのサービスと連携
1. Gitのインストール方法
Windows での Gitインストール
手順1:公式サイトからダウンロード
- Git公式サイトにアクセス
- 「Download for Windows」をクリック
https://git-scm.com/
┌─────────────────────────────────────┐
│ Git - fast-version-control │
│ │
│ [Download 2.43.0 for Windows] │
│ │
│ Downloads for Linux and Unix │
│ Downloads for macOS │
└─────────────────────────────────────┘
手順2:インストーラーの実行
- ダウンロードした
Git-2.43.0-64-bit.exeを実行 - インストール画面が表示されます
Git Setup
┌─────────────────────────────────────┐
│ Welcome to the Git Setup Wizard │
│ │
│ This will install Git on your │
│ computer. │
│ │
│ [Next >] [Cancel] │
└─────────────────────────────────────┘
手順3:インストール設定
重要な設定項目:
- デフォルトエディタの選択
- Vim(上級者向け)
- Visual Studio Code(推奨)
- Notepad++
Choosing the default editor
┌─────────────────────────────────────┐
│ Which editor would you like Git to │
│ use? │
│ │
│ ○ Use Vim │
│ ● Use Visual Studio Code │
│ ○ Use Notepad++ │
│ │
│ [< Back] [Next >] [Cancel] │
└─────────────────────────────────────┘
- PATH環境変数の設定
- 「Git from the command line and also from 3rd-party software」を選択(推奨)
Adjusting your PATH environment
┌─────────────────────────────────────┐
│ How would you like to use Git? │
│ │
│ ○ Use Git from Git Bash only │
│ ● Git from the command line and │
│ also from 3rd-party software │
│ ○ Use Git and optional Unix tools │
│ │
│ [< Back] [Next >] [Cancel] │
└─────────────────────────────────────┘
Mac での Gitインストール
方法1:Homebrewを使用(推奨)
# Homebrewのインストール(未インストールの場合)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Gitのインストール
brew install git
方法2:Xcodeコマンドラインツールを使用
# Xcodeコマンドラインツールのインストール
xcode-select --install
Xcodeのインストールダイアログが表示されます:
Install Command Line Developer Tools
┌─────────────────────────────────────┐
│ The "git" command requires the │
│ command line developer tools. │
│ Would you like to install the tools │
│ now? │
│ │
│ [Get Xcode] [Install] [Cancel] │
└─────────────────────────────────────┘
Linux での Gitインストール
Ubuntu/Debian の場合
# パッケージリストの更新
sudo apt update
# Gitのインストール
sudo apt install git
CentOS/RHEL の場合
# Gitのインストール
sudo yum install git
Fedora の場合
# Gitのインストール
sudo dnf install git
2. Gitの初期設定
インストールが完了したら、初期設定を行います。
基本設定
ユーザー名とメールアドレスの設定
# ユーザー名の設定
git config --global user.name "あなたの名前"
# メールアドレスの設定
git config --global user.email "your.email@example.com"
実際の例:
git config --global user.name "Taro Yamada"
git config --global user.email "taro.yamada@example.com"
デフォルトブランチ名の設定
# デフォルトブランチ名をmainに設定
git config --global init.defaultBranch main
エディタの設定
# Visual Studio Codeを設定
git config --global core.editor "code --wait"
# Vimを設定
git config --global core.editor vim
# nanoを設定
git config --global core.editor nano
設定の確認
# 設定一覧の表示
git config --list
# 特定の設定値の確認
git config user.name
git config user.email
出力例:
user.name=Taro Yamada
user.email=taro.yamada@example.com
init.defaultbranch=main
core.editor=code --wait
追加設定(オプション)
改行コードの自動変換設定
Windows の場合:
git config --global core.autocrlf true
Mac/Linux の場合:
git config --global core.autocrlf input
カラー表示の有効化
git config --global color.ui auto
エイリアス(ショートカット)の設定
# よく使うコマンドのエイリアス
git config --global alias.st status
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.cm commit
設定後は以下のように短縮形でコマンドを実行できます:
git st # git status の代わり
git co # git checkout の代わり
git br # git branch の代わり
git cm # git commit の代わり
3. インストールの動作確認
バージョンの確認
git --version
出力例:
git version 2.43.0
Helpの表示
git help
出力例:
usage: git [--version] [--help] [-C <path>] [-c <name>=<value>]
[--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
[-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
[--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
[--super-prefix=<path>] [--config-env=<name>=<envvar>]
<command> [<args>]
These are common Git commands used in various situations:
start a working area (see also: git help tutorial)
clone Clone a repository into a new directory
init Create an empty Git repository or reinitialize an existing one
work on the current change (see also: git help everyday)
add Add file contents to the index
mv Move or rename a file, a directory, or a symlink
reset Reset current HEAD to the specified state
rm Remove files from the working tree and from the index
設定内容の確認
git config --list --global
4. トラブルシューティング
よくある問題と解決方法
問題1:「git: command not found」エラー
原因: PATHが正しく設定されていない
解決方法:
- インストールを再実行
- ターミナルを再起動
- PATH環境変数を手動で設定
問題2:HTTPSエラー
原因: SSL証明書の検証エラー
解決方法:
# SSL検証を無効化(一時的)
git config --global http.sslVerify false
# 企業環境の場合はプロキシ設定
git config --global http.proxy http://proxy.company.com:8080
問題3:認証エラー
原因: GitHubなどのリモートリポジトリへの認証設定不備
解決方法:
# 認証情報のキャッシュ設定
git config --global credential.helper cache
# Windows の場合
git config --global credential.helper manager-core
# Mac の場合
git config --global credential.helper osxkeychain
5. 次のステップ
Gitのインストールと初期設定が完了したら、次は以下を学習しましょう:
Gitの基本コマンド
git init:リポジトリの初期化git add:ファイルをステージングgit commit:変更をコミット
GitHubとの連携
- GitHubアカウントの作成
- SSH鍵の設定
- リポジトリのクローン
ブランチの使い方
- ブランチの作成・切り替え
- マージの基本
まとめ
この記事では、Git初心者向けにインストールから初期設定までを画面付きで解説しました。
重要なポイント:
- OS別のインストール方法を理解する
- ユーザー名とメールアドレスの設定は必須
- デフォルトブランチ名をmainに設定
- 動作確認でインストールの成功を確認
Gitは最初は複雑に感じるかもしれませんが、基本的なコマンドから始めて徐々に慣れていけば、必ず使いこなせるようになります。
次回は「Git基本コマンド入門」について解説予定です。お楽しみに!
関連記事: