0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Mac】Git 環境構築

0
Posted at

1. Git をインストール

Mac には最初から Git が入っていることが多い。ターミナルを開いて確認する。

git --version

git version 2.x.x のように表示されれば OK。次の手順へ進む。

表示されない、または初回実行時に「開発者ツールをインストール」のダイアログが出た場合は、そのままインストールを進める(数分かかる)。完了後にもう一度 git --version で確認する。

Homebrew で最新版を入れたい場合(任意)

brew install git

インストール後は ターミナルを一度閉じて開き直す

2. 初期設定

自分の名前とメールアドレスを設定する。これはコミットの記録に使われる。

git config --global user.name "自分の名前"
git config --global user.email "自分のメールアドレス"

(例)

git config --global user.name "Asahi Kawanobe"
git config --global user.email "asahi@example.com"

3. デフォルトブランチ名を main に

git config --global init.defaultBranch main

4. 動作確認(コミットまで)

適当な場所に練習用フォルダを作って、コミットまでできるか確認する。

cd ~/Desktop
mkdir git-test
cd git-test
git init

適当なファイルを作成。

echo "hello" > hello.txt

コミットする。

git add hello.txt
git commit -m "first commit"

1 file changed, ... のような表示が出れば OK。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?