2
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?

More than 3 years have passed since last update.

gitの初期設定

Last updated at Posted at 2020-04-22

個人や会社で新しいパソコンを使うことになったとき、gitの初期設定って忘れてますよね!
というわけで、そういうときにさっと設定できるようにメモです!

結論

自分は下記の最低限の設定のみをしています。

# ユーザー名を指定、git log, git show, git blame などで表示される
git config --global user.name "MyoujiNamae"

# メールアドレスを指定、git log などで表示される
git config --global user.email "e-mail@address.com"

# ファイルパスなどを表示するとき(git status, git ls-filesなどで)特殊文字(日本語)をクオートして表示しないようにする
git config --global core.quotepath false

# commit時やcheckout時に自動で改行コードが変更(CRLF → LFなど)されないようにする
git config --global core.autocrlf false

個人的にはユーザー名の設定では名前と苗字の間はスペース開けないほうがよいかなと
PhpStormなどのJetBrain製のエディタのAnnotateで、例えば First Family と設定すると後ろの名前の Family が表示されるため

有効範囲、--local, --global, --system

--local

リポジトの設定(指定なしの場合これ)

--global

PCユーザーの設定

--system

システム(OS)での設定

config の確認

コマンドで確認

現在反映されている設定は下記で確認できる

git config -l

--local など有効範囲を指定するとその有効範囲の設定のみ表示される

git config -l --local

ファイルで確認

下記のようにファイルに設定が記述されている

[user]
        email = e-mail@address.com
        name = MyoujiNamae
[core]
        quotepath = false
        autocrlf = false

--local のファイルの場所

(リポジトリのroot)/.git/config

--global のファイルの場所

~/.gitconfig
2
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
2
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?