MacBook Pro Git設定手順
こんにちは、@yshr10icです。
MacBook ProでのGitの設定手順を備忘録として残していきます。
前提条件
- PC:MacBook Pro(13-inch, 2020, Four Thunderbolt 3 ports)
- OS:macOS Catalina(バージョン:10.15.4)
- Homebrew:2.2.17
Homebrewより、最新のGitのインストール
$ brew install git $ git --version git version 2.24.3 (Apple Git-128)
ユーザ名、メールアドレスの設定
$ git config --global user.name xxx $ git config --global user.email "xxx@example.com" $ git config --global -l user.name xxx user.email xxx@example.com
ディレクトリ、ファイルの設定
$ mkdir ~/.ssh $ touch ~/.ssh/config $ chmod 700 ~/.ssh $ chmod 600 ~/.ssh/*
SSHのConfig設定
$ vi ~/.ssh/config Host * StrictHostKeyChecking no UserKnownHostsFile=/dev/null ServerAliveInterval 15 ServerAliveCountMax 30 AddKeysToAgent yes UseKeychain yes IdentitiesOnly yes
global .gitignoreの設定
$ mkdir -p ~/.config/git $ touch ~/.config/git/ignore $ vi ~/.config/git/ignore .DS_Store
GitHub SSH接続設定
GitHub用の秘密鍵、公開鍵を作成
$ ssh-keygen -t ed25519 -N "" -f ~/.ssh/github -C xxx@example.com $ pbcopy < ~/.ssh/github.pub
https://github.com/settings/keysを開いて、New SSH Key
を押す。
Title
に分かりやすい名前を設定し、Key
に先ほどコピーした公開鍵を貼り付ける。
Add SSH Key
を押す。
設定の追記
$ vi ~/.ssh/config Host github.com IdentityFile ~/.ssh/github User git
動作確認
$ ssh -T github.com Warning: Permanently added 'github.com,13.114.40.48' (RSA) to the list of known hosts. Hi yshr10ic! You've successfully authenticated, but GitHub does not provide shell access.
参考サイト
以下、参考にさせていただいたサイトです!