こちらの記事では、WindowsとMacにGitをインストールする方法について画像付きで分かりやすくまとめています。

- 漫画形式で読みやすく理解しやすい
- GitHubを使った実践的な内容も分かりやすい


Amazon Kindle Unlimitedに登録すると、月額980円で読み放題だからオススメだよ!



初回30日間は無料だから、まだ登録したことのない人はぜひ試してみてね!
変数名/関数名にもう悩まない!


- 美しいコードが書けるが自然と書けるようになる
- 他の開発者が理解しやすいコードになる


WindowsにGitをインストールする手順
まず始めに「Git for Windows」のページにアクセスします。


Git for Windowsのページにアクセスしたら「Download」ボタンをクリックします。


ダウンロード完了したexeファイルを開くと最初にGNUライセンスのウィンドウが表示されます。内容に同意したら「Next」をクリックします。


Gitのインストール先のディレクトリを指定します。
デフォルトはCドライブ内のProgram Filesフォルダ内にGitが追加されます。インストール先を変更したい人は「Browse…」のボタンをクリックしディレクトリを選択します。


インストールオプションを選択します。
デフォルトでは「Git Bash Here」「Git GUI Here」「Git LFS(Large File Support)」「Associate .git configuration files with the default text editor」「Associate .sh files to be run with Bash」が選択されています。
オプション | 説明 |
---|---|
On the Desktop | デスクトップ上にGitアイコンを追加する |
Git Bash Here | Git Bashをコンテキストメニューに追加する |
Git GUI Here | Git GUIをコンテキストメニューに追加する |
Git LFS(Large File Support) | Gitの拡張機能です。 Gitは動画や高画質の画像などの大容量のファイルを扱うことが不得意です。そこでGit LFSを使うことで大容量のファイルを効率よく扱うことが可能になります。 |
Associate .git configuration files with the default text editor | エクスプローラーで「.git」で始まるファイルを開くと自動でテキストエディタが起動する |
Associate .sh files to be run with Bash | エクスプローラーで拡張子が「.sh」のファイルを開くと自動でGit Bashが起動し実行する |
Check daily for Git for Windows updates | Git for Windowsのアップデート情報が公開された時に通知が来る |
(NEW!)Add a Git Bash Profile to Windows Terminal | Windows TerminalにGit Bashを追加する |


スタートメニューにGitを追加します。
デフォルト設定の場合スタートメニューに追加されるため、追加したくない場合は下にあるチェックボックス「Don’t create a Start Menu folder」を選択します。


デフォルトのエディタを選択します。インストールされているエディタであればどれを選択しても問題ありません。


git initコマンドでリポジトリを作成した時のブランチ名を設定します。
項目 | 説明 |
---|---|
Let Git decide | ブランチ名をmaster |
Override the default branch name for new repositories | 指定したブランチ名がデフォルト |
デフォルトの「Let Git decide」を選択するとブランチ名がmasterになります。
今までのGitはmasterブランチでしたが今後masterブランチからmainブランチに変更される予定です。


PATH環境変数の設定をします。
項目 | 説明 |
---|---|
Use Git from Git Bash only | GitをGit Bashのみで使用 |
Git from the command line and also from 3rd-party-software | GitをPowerShellなどのGit Bash以外でも使用可能 |
Use Git and optional Unix tools from the Command Prompt | PowerShellなどでGitコマンドの他にUnixのコマンドが使用可能 |


gitでSSH接続をする場合に、OpenSSHを利用するか外部のOpenSSHを利用するかを選択します。
項目 | 説明 |
---|---|
Use bundled OpenSSH | ssh.exeをインストールする |
Use external OpenSSH | ssh.exeをインストールしない |


gitでHTTPS接続をする場合に、OpenSSLのルート証明書を使うか、WindowsのSecure Channelのルート証明書を使うか選択します。
項目 | 説明 |
---|---|
Use the OpenSSL library | OpenSSLのルート証明書を使う |
Use the native Windows Secure Channel library | WindowsのSecure Channelのルート証明書を使う |


チェックアウトとコミット時の改行コードの自動変換設定をします。
項目 | 説明 |
---|---|
Checkout Windows-style,commit Unix-style line endings | チェックアウト:CR-LF コミット:LF |
Checkout as-is, commit Unix-style line endings | コミット:LF |
Checkout as-is, commit as-is | 改行コードの自動変換無し |


Git Bashで使用するターミナルを選択します。
項目 | 説明 |
---|---|
Use MinTTY(the default terminal of MSYS2) | MinTTYを使用 |
Use Windows’ default console window | Windowsの標準コンソールを使用 |


git pullコマンド実行時の挙動を設定します。
項目 | 実行されるコマンド |
---|---|
Default(fase-forward or merge) | git pull –ff |
Rebase | git pull –rebase |
Only ever fase-forward | git pull –ff-only |


httpsでリモートリポジトリに接続する際の認証について設定します。
項目 | 実行されるコマンド |
---|---|
Git Credential Manager | Credential Managerをインストールする リモートリポジトリに接続する際に毎回行われる認証を省く |
None | Credential Managerをインストールしない |


オプションの設定をします。
項目 | 実行されるコマンド |
---|---|
Enable file system caching | ファイルのキャッシュを削除し動作を高速化する |
Enable symbolic links | リポジトリ内でシンボリックリンクを使用する |


試験運用中のオプション設定をします。
項目 | 実行されるコマンド |
---|---|
Enable experimental support for pseudo consoles. | Git Bash Window上でNodeやPythonのコンソールを使用できる |
Enable experimental built-in file system monitor | FS Monitorを使用してファイル監視を行うことで、Gitコマンドが高速化する |


インストール完了後に行われる操作の設定をします。
項目 | 実行されるコマンド |
---|---|
Launch Git Bash | Git Bashを起動する |
View Release Notes | ブラウザが立ち上がり、Gitのリリースノートが開かれる |


インストールが完了したら、Windowsマークの左にある検索バーでGit Bashと入力しアプリを開きます。
ターミナルが起動するので、下記のコマンドを実行して正しくインストールされているか確認しましょう。
git version
>> git version 2.35.1.windows.2
以上でWindowsにGitをインストール手順が終了です。
MacにGitをインストールする手順
MacにはデフォルトでGitがインストールされています。今から解説することはMacに正しくGitがインストールされているか確認する作業になります。
下記のコマンドをターミナル上で実行してください。
git version
>> git version 2.32.0
コマンドを実行すると、「git version x.xx.x」と表示がされます。
gitをインストールするタイミングや環境によってバージョンが異なりますので上記に記載されている「2.32.0」は気にしないで大丈夫です。
まとめ
今回はWindowsとMacにGitをインストールする方法について解説しました。
Gitとセットで使われることが多いGitHubの登録をまだしていない方や、GitとGitHubを実際に使ってみたいという方向けに下記の記事でGitHubの登録方法についてとリポジトリの作成からpushまでの一連の流れを別記事で解説しているので、ぜひ参考にしてください。





