git config とは、Git の動き(名前・メール、push や pull のやり方、表示の色など)を設定するコマンドです。設定は system・global・local・worktree の4か所に保存され、より狭い範囲の設定が優先されます。

この記事では、最近よく推奨される設定14項目を 「効果・既定値・導入バージョン」つきの一覧表にし、Git 2.43 で設定する前と後の動きを実際に実行して確かめました。あわせて、どの設定がどのファイルから来ているかを調べる --show-origin --show-scope、includeIf でディレクトリごとに名前とメールを切り替える方法、そのまま貼れる .gitconfig 全文と alias 集、設定の確認・削除のコマンドを紹介します。

検証環境:Git 2.43.0(Ubuntu)。2026年9月28日時点の最新版は Git 2.56.0(git-scm.com で確認)です。表の既定値は Git 公式ドキュメント(git-config)で確認し、動きは 2.43 で確かめています。

git config設定の早見表(やりたいこと別)

やりたいこと コマンド
名前とメールを設定する git config --global user.name "名前" / user.email
設定をすべて見る(どこの設定かも) git config --list --show-origin --show-scope
1つの値を見る git config --get pull.rebase(git config pull.rebase も同じ)
その値がどのファイル由来か見る git config --show-origin --show-scope core.editor
同じキーの全部の値を見る git config --get-all キー
パターンで探す git config --get-regexp '^alias\.'
設定を消す git config --global --unset キー
複数の値をまとめて消す git config --global --unset-all キー
セクションごと消す git config --global --remove-section alias
エディタで直接編集する git config --global --edit
このリポジトリだけ設定する git config user.email ...(--local は省略可)
1回だけ設定を変えて実行する git -c pull.rebase=false pull
ディレクトリごとに設定を変える [includeIf "gitdir:~/work/"]
alias を作る git config --global alias.st "status -sb"
既定のブランチ名を main に git config --global init.defaultBranch main
初回 push で追跡ブランチも作る git config --global push.autoSetupRemote true
pull を rebase にする git config --global pull.rebase true

本記事の内容は、ご自由にお使いください。
ご利用の際は、出典として本ページへのリンクを記載いただけますようお願いします。

(記載例)出典:株式会社RJC「git config設定一覧とおすすめalias|最新Gitで入れるべき推奨値」

設定の4つの範囲と優先順位

Git は4つの設定ファイルを順に読み、あとから読んだ値で上書きします。 そのため、狭い範囲の設定ほど優先されます。

範囲 オプション ファイルの場所 対象
system --system $(prefix)/etc/gitconfig(例:/etc/gitconfig) そのマシンの全ユーザー
global --global ~/.gitconfig または ~/.config/git/config 自分のすべてのリポジトリ
local --local(省略時の既定) .git/config そのリポジトリだけ
worktree --worktree .git/config.worktree そのワークツリーだけ
command git -c キー=値 (ファイルなし) その1回の実行だけ
flowchart LR
    S[system] --> G[global] --> L[local] --> W[worktree] --> C["-c(コマンド)"]
    C --> R[最終的な値]

右へ行くほど優先されます。--worktree は extensions.worktreeConfig を true にしたリポジトリで使えます(git worktree で複数の作業フォルダを使うときの設定です)。

実行結果:同じキーを4か所に設定してみる

core.editor を4つの範囲すべてに設定し、どれが使われるかを確かめました。

$ git config --system core.editor nano
$ git config --global core.editor vim
$ git init -q -b main repo && cd repo
$ git config --local core.editor "code --wait"
$ git config extensions.worktreeConfig true
$ git config --worktree core.editor emacs

$ git config --list --show-origin --show-scope
system  file:/path/to/system-gitconfig  core.editor=nano
global  file:/path/to/home/.gitconfig   core.editor=vim
global  file:/path/to/home/.gitconfig   user.name=Sato Hanako
global  file:/path/to/home/.gitconfig   user.email=sato@example.com
local   file:.git/config    core.repositoryformatversion=0
local   file:.git/config    core.filemode=true
local   file:.git/config    core.bare=false
local   file:.git/config    core.logallrefupdates=true
local   file:.git/config    core.editor=code --wait
local   file:.git/config    extensions.worktreeconfig=true
worktree    file:.git/config.worktree   core.editor=emacs

(検証のため、system の設定ファイルは環境変数 GIT_CONFIG_SYSTEM で作業フォルダ内のファイルに向けています。パスは /path/to に置き換えています)

$ git config --show-origin --show-scope core.editor
worktree    file:.git/config.worktree   emacs

$ git config --get-all --show-scope core.editor
system  nano
global  vim
local   code --wait
worktree    emacs

$ git -c core.editor=nvim config --show-scope --show-origin core.editor
command command line:   nvim

--list は読んだ順にすべて並べ、--get(キーだけ指定)は最後に読んだ値を返します。 「設定したのに効かない」ときは、--show-origin --show-scope で別の範囲に同じキーがないかを確認するのが近道です。なお、エディタは環境変数 GIT_EDITOR があればそちらが優先されます(git var GIT_EDITOR で実際に使われるエディタを確認できます)。

推奨設定の一覧(効果・既定値・導入バージョン)

既定値は Git 公式ドキュメント(git-config)の記載、導入バージョンは各リリースノートでの追加時期です。 すべて Git 2.43 で設定できることを確かめています。

設定 おすすめ値 効果 既定値 導入
init.defaultBranch main git init の最初のブランチ名 master(ヒントを表示) 2.28
push.autoSetupRemote true 初回の git push で追跡ブランチも作る false 2.37
pull.rebase true pull でマージではなく rebase する false 1.7.9
pull.ff only(rebase を使わない場合) 早送りできるときだけ pull する 未設定 古くからある
fetch.prune true リモートで消えたブランチの追跡を fetch 時に消す false 1.8.5
rerere.enabled true 一度解いたコンフリクトの解き方を覚えて再利用 false 古くからある
diff.algorithm histogram(好みで) 差分の計算方法 myers 1.8.4
merge.conflictStyle zdiff3 コンフリクトに「元の内容」も表示 merge 2.35(zdiff3)
rebase.autoStash true 未コミットの変更があっても rebase できる false 2.6
branch.sort -committerdate git branch を最近更新した順に refname(名前順) 2.19
column.ui auto git branch などを端末で横に並べる 未設定 1.7.11
help.autocorrect prompt 打ち間違えたコマンドを確認して実行 0(実行しない) 数値は古くから。prompt は 2.43 で動作確認
commit.verbose true コミットメッセージ編集画面に差分を表示 false 2.9
core.autocrlf Windows:true/Mac・Linux:input 改行コード(CRLF・LF)の変換 false 古くからある
core.editor 普段使うエディタ コミットメッセージ等の編集に使う 環境変数・vi など 古くからある

迷ったら、init.defaultBranch・push.autoSetupRemote・pull.rebase(または pull.ff only)・fetch.prune・merge.conflictStyle の5つから入れると、日々の操作で効果を感じやすいです。 以下、設定前と後の動きを実行結果で見ていきます。

init.defaultBranch:最初のブランチ名を決める

$ git init a
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint: 
hint:   git config --global init.defaultBranch <name>
(中略)
$ git -C a symbolic-ref --short HEAD
master

$ git config --global init.defaultBranch main
$ git init b2
Initialized empty Git repository in /path/to/b2/.git/
$ git -C b2 symbolic-ref --short HEAD
main

設定するとヒントが消え、最初から main になります。 GitHub などのホスティングサービスの既定(main)とそろえておくと、初回 push で迷いません。

push.autoSetupRemote:初回pushの -u を不要にする

$ git switch -c feature/x
$ git push
fatal: The current branch feature/x has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin feature/x

To have this happen automatically for branches without a tracking
upstream, see 'push.autoSetupRemote' in 'git help config'.

$ git config --global push.autoSetupRemote true
$ git push
To /path/to/origin.git
 * [new branch]      feature/x -> feature/x
branch 'feature/x' set up to track 'origin/feature/x'.

新しいブランチでも git push だけで追跡ブランチ(upstream)が設定されます。 push.default が既定の simple のままで動きます。

pull.rebase と pull.ff:分岐したときの pull の動きを決める

ローカルとリモートの両方に新しいコミットがある(分岐している)状態で、何も設定せずに git pull すると、Git 2.43 では次のように止まります。

$ git pull
(fetch の表示は省略)
hint: You have divergent branches and need to specify how to reconcile them.
hint: You can do so by running one of the following commands sometime before
hint: your next pull:
hint: 
hint:   git config pull.rebase false  # merge
hint:   git config pull.rebase true   # rebase
hint:   git config pull.ff only       # fast-forward only
(中略)
fatal: Need to specify how to reconcile divergent branches.

$ git config --global pull.rebase true
$ git pull
Successfully rebased and updated refs/heads/main.
$ git log --oneline --graph
* fc2e65e d1
* 84ea476 c1
* 110eebe init
設定 分岐しているときの動き 向いている使い方
pull.rebase true 自分のコミットをリモートの上に積み直す(一直線の履歴) 自分のブランチで作業し、こまめに pull する
pull.rebase false マージコミットを作る マージの記録を残したい
pull.ff only 止めて、どうするか自分で決める 意図しない統合を避けたい

どれを選んでもよく、チームの方針に合わせるのが一番です。 merge と rebase の違いそのものは別の記事で詳しく扱っています。

fetch.prune:消えたリモートブランチの追跡を片付ける

$ git branch -r
  origin/HEAD -> origin/main
  origin/feature/x
  origin/main

$ git config --global fetch.prune true
$ git fetch
From /path/to/origin
 - [deleted]         (none)     -> origin/feature/x
$ git branch -r
  origin/HEAD -> origin/main
  origin/main

リモートで削除済みの origin/feature/x が、fetch のたびに自動で片付きます。 ローカルブランチ(feature/x)そのものは消えません。

merge.conflictStyle zdiff3 と rerere.enabled:コンフリクトを解きやすくする

同じ行を両方のブランチで変えたときのコンフリクト表示です。

(既定の merge スタイル)
title
<<<<<<< HEAD
stock = 3
=======
stock = 2
>>>>>>> topic
end

(zdiff3)
title
<<<<<<< HEAD
stock = 3
||||||| 1b31019
stock = 1
=======
stock = 2
>>>>>>> topic
end

zdiff3 では ||||||| の下に「分かれる前の元の内容(stock = 1)」が出ます。 「main は1→3、topic は1→2に変えた」と分かるので、どちらを採るか判断しやすくなります。zdiff3 は diff3 の表示から、両側で共通の行をマーカーの外に出したものです。

rerere(reuse recorded resolution)を有効にすると、解いたコンフリクトを覚えます。同じマージをやり直したときの結果です。

$ git merge topic
Auto-merging s.txt
CONFLICT (content): Merge conflict in s.txt
Recorded preimage for 's.txt'
(解いて git add・git commit)
Recorded resolution for 's.txt'.

(同じマージをもう一度)
$ git merge topic
Auto-merging s.txt
CONFLICT (content): Merge conflict in s.txt
Resolved 's.txt' using previous resolution.
$ cat s.txt
title
stock = 3
end

2回目は前回の解き方が自動で当てはめられました。 rebase のやり直しや、長く続くブランチへの繰り返しのマージで手間が減ります。内容を確認してから git add するのは同じです。

rebase.autoStash:未コミットの変更があっても rebase する

$ git rebase mid
error: cannot rebase: You have unstaged changes.
error: Please commit or stash them.

$ git config --global rebase.autoStash true
$ git rebase mid
Created autostash: 88acc4e
Applied autostash.
Successfully rebased and updated refs/heads/alpha.

rebase の前に自動で stash し、終わったら戻します。 pull.rebase true と組み合わせると、作業中でも git pull できるようになります。戻すときに変更がぶつかった場合は stash に残るので、git stash list で確認できます。

branch.sort と column.ui:ブランチ一覧を見やすくする

$ git branch
  alpha
* main
  mid
  zeta

$ git config --global branch.sort -committerdate
$ git branch
  mid
  alpha
  zeta
* main

$ git -c column.ui=always branch
  alpha   mid     zeta  * main

-committerdate(先頭のマイナスは降順)で、最近コミットしたブランチが上に来ます。 ブランチが増えても、今触っているものがすぐ見つかります。column.ui auto は端末に出すときだけ横に並べ、パイプでは1行1件のままです(上の例は確認のため always にしています)。

help.autocorrect:打ち間違いを補う

$ git stauts
git: 'stauts' is not a git command. See 'git --help'.

The most similar command is
    status

$ git config --global help.autocorrect immediate
$ git stauts
WARNING: You called a Git command named 'stauts', which does not exist.
Continuing under the assumption that you meant 'status'.
On branch main

$ git config --global help.autocorrect 10
$ git stauts
WARNING: You called a Git command named 'stauts', which does not exist.
Continuing in 1.0 seconds, assuming that you meant 'status'.
値 動き
0/false(既定) 候補を表示するだけ
prompt 実行してよいか確認する(端末で使うとき)
immediate すぐに実行する
正の数 その数×0.1秒待ってから実行する(10 で1秒)
never 候補も表示しない

おすすめは prompt です。 意図と違うコマンドが動く前に確認できます。

commit.verbose:コミット時に差分を見ながら書く

git commit で開くエディタの中身を、GIT_EDITOR=cat で表示した結果です(メッセージを書かないので、最後はコミットが中止されます)。

$ git config --global commit.verbose true
$ GIT_EDITOR=cat git commit
(前半は省略)
# Changes to be committed:
#   modified:   note.txt
#
# ------------------------ >8 ------------------------
# Do not modify or remove the line above.
# Everything below it will be ignored.
diff --git a/note.txt b/note.txt
index 587be6b..bfb45d7 100644
--- a/note.txt
+++ b/note.txt
@@ -1 +1 @@
-x
+stock = 5
Aborting commit due to empty commit message.

差分を見ながらメッセージを書けるので、「何を変えたか」を正確に書けます。 差分部分はメッセージに含まれません。

core.autocrlf:改行コードをそろえる

$ printf 'a\r\nb\r\n' > crlf.txt
$ git config --global core.autocrlf input
$ git add crlf.txt
warning: in the working copy of 'crlf.txt', CRLF will be replaced by LF the next time Git touches it
$ git ls-files --eol crlf.txt
i/lf    w/crlf  attr/                   crlf.txt

$ git config --global core.autocrlf false
$ git add crlf.txt
$ git ls-files --eol crlf.txt
i/crlf  w/crlf  attr/                   crlf.txt

i/ はリポジトリに入る改行、w/ は作業フォルダの改行です。 input ではリポジトリに LF で記録されました。Windows では true(取り出すときに CRLF、記録するときに LF)、Mac・Linux では input が一般的です。チームで確実にそろえたいときは、リポジトリに .gitattributes(例:* text=auto)を置くと、各自の設定に左右されません。

diff.algorithm:差分の計算方法(好みで選ぶ)

histogram は、ファイル中で出現回数の少ない行を手がかりに対応を取る方式で、関数の移動などで読みやすい差分になることが多いとされます。一方、既定の myers は変更行数が最小になる差分を求めます。検証で試した例では、myers のほうが短い差分になるケースもありました。

(myers:変更は load の中身1行)
+def sync():
+    new_step()
+    return None
+
 def load():
-    load_step()
+    load_v2()
     return None

(histogram:def load(): の行も消して足し直している)
-def load():
-    load_step()
+def sync():
+    new_step()
+    return None
+
+def load():
+    load_v2()
     return None

どちらが読みやすいかはコードによるので、git diff --diff-algorithm=histogram で何度か比べてから設定するとよいでしょう。 設定しても、1回だけ --diff-algorithm=myers で戻せます。

includeIfでディレクトリ別に名前・メールを切り替える

[includeIf "条件"] を使うと、条件に合うときだけ別の設定ファイルを読み込めます。 仕事用と個人用でメールアドレスを分けるのに便利です。

# ~/.gitconfig
[user]
    name = Sato Hanako
    email = hanako@example.com
[includeIf "gitdir:~/work/"]
    path = ~/.gitconfig-work
[includeIf "gitdir:~/oss/"]
    path = ~/.gitconfig-oss
# ~/.gitconfig-work
[user]
    name = Hanako Sato (Team A)
    email = hanako.sato@team-a.example.com
# ~/.gitconfig-oss
[user]
    email = hanako@users.noreply.example.org

実行結果

$ cd ~/work/app && git config --show-origin user.email
file:~/.gitconfig-work  hanako.sato@team-a.example.com
$ git config user.name
Hanako Sato (Team A)

$ cd ~/oss/lib && git config --show-origin user.email
file:~/.gitconfig-oss   hanako@users.noreply.example.org
$ git config user.name
Sato Hanako

$ cd ~/misc/tmp && git config --show-origin user.email
file:~/.gitconfig   hanako@example.com

--show-origin で、どのファイルの値が使われたかが分かります。 oss 側は email だけを上書きしたので、name は ~/.gitconfig のものが使われています。

つまずきやすい点(検証結果)

確認したこと 結果 ポイント
gitdir:~/work(末尾の / なし) 切り替わらなかった 末尾を / にすると「その下すべて」に合う
~/work/app/src(リポジトリの中のサブフォルダ) 切り替わった 判定は .git の場所で行われる
~/work/notrepo(Git リポジトリでないフォルダ) 切り替わらなかった gitdir はリポジトリの中でだけ働く
includeIf より後ろに [user] email を書いた 後ろの値が使われた includeIf はファイルの最後に書く
読み込むファイルが存在しない エラーにならず無視された ファイル名の打ち間違いに注意

gitdir 以外の条件

条件 例 合うとき
gitdir: gitdir:~/work/ リポジトリの場所
gitdir/i: gitdir/i:C:/Work/ 同上、大文字・小文字を区別しない(Windows 向け)
onbranch: onbranch:release/** 今のブランチ名
hasconfig:remote.*.url: hasconfig:remote.*.url:https://git.example.com/team-a/** リモートの URL

hasconfig:remote.*.url: を使うと、置き場所に関係なく「このサーバーのリポジトリなら仕事用」と切り替えられます。 Git 2.43 で、リモート URL が合うリポジトリに仕事用のメールが使われることを確認しました。

$ git remote add origin https://git.example.com/team-a/tool.git
$ git config --show-origin user.email
file:~/.gitconfig-work  hanako.sato@team-a.example.com

そのまま貼れる.gitconfig全文とalias集

上の推奨設定と alias をまとめた完成形です。 名前とメールを書き換えて ~/.gitconfig に保存してください(Git 2.37 以降を想定。2.38 未満では rebase.updateRefs は無視されます)。

# ~/.gitconfig(名前とメールは自分のものに書き換える)
[user]
    name = Sato Hanako
    email = hanako@example.com

[init]
    defaultBranch = main

[core]
    editor = vim
    autocrlf = input        # Windows では true
    quotepath = false       # 日本語のファイル名を \343... ではなくそのまま表示

[fetch]
    prune = true

[pull]
    rebase = true

[push]
    autoSetupRemote = true

[rebase]
    autoStash = true
    autoSquash = true       # fixup! コミットを rebase -i で自動で並べる
    updateRefs = true       # 積み重ねたブランチも一緒に移動する(2.38 以降)

[merge]
    conflictStyle = zdiff3

[rerere]
    enabled = true

[diff]
    algorithm = histogram   # 好みで。myers に戻してもよい
    colorMoved = default    # 移動しただけの行を別の色で表示

[commit]
    verbose = true

[branch]
    sort = -committerdate

[tag]
    sort = version:refname  # v1.10 を v1.9 の後に並べる

[column]
    ui = auto

[help]
    autocorrect = prompt

[alias]
    st = status -sb
    sw = switch
    br = branch
    cm = commit -m
    amend = commit --amend --no-edit
    unstage = restore --staged
    undo = reset --soft HEAD~1
    back = switch -
    pf = push --force-with-lease --force-if-includes
    lg = log --graph --format='%C(yellow)%h%C(reset) %C(cyan)%as%C(reset) %C(green)%<(11,trunc)%an%C(reset)%C(auto)%d%C(reset) %s'
    last = log -1 --stat
    root = rev-parse --show-toplevel
    aliases = config --get-regexp ^alias\\.
    gone = !git fetch -p && git branch -vv | awk '/: gone]/{print $1}'

# 仕事用ディレクトリだけ名前・メールを切り替える(ファイルの最後に書く)
[includeIf "gitdir:~/work/"]
    path = ~/.gitconfig-work

# 以降はコメントです。このファイルを置いた状態で git config --list --show-origin がエラーなく読めること、alias が動くことを Git 2.43 で確認しました。

alias の一覧と出力例

alias 中身 用途
st status -sb 短い status(ブランチ名つき)
sw / br switch / branch よく使うコマンドを短く
cm commit -m メッセージつきでコミット
amend commit --amend --no-edit 直前のコミットに追加(メッセージそのまま)
unstage restore --staged add を取り消す
undo reset --soft HEAD~1 直前のコミットを取り消し、変更はステージに残す
back switch - 1つ前のブランチに戻る
pf push --force-with-lease --force-if-includes 他の人の push を上書きしにくい強制 push(2.30 以降)
lg / last log の整形 履歴を見やすく
root rev-parse --show-toplevel リポジトリの最上位のパス
aliases config --get-regexp ^alias\. 登録した alias の一覧
gone !git fetch -p && ... リモートで消えたローカルブランチを一覧
$ git cm "在庫ファイルを追加"
[main (root-commit) cc411ee] 在庫ファイルを追加
 1 file changed, 1 insertion(+)
 create mode 100644 a.txt
$ git cm "在庫を更新"
[main b6c4a1b] 在庫を更新
 1 file changed, 1 insertion(+)

$ git lg
* b6c4a1b 2026-10-02 Sato Hanako (HEAD -> main) 在庫を更新
* cc411ee 2026-10-02 Sato Hanako 在庫ファイルを追加

$ git undo
$ git st
## main
M  a.txt
$ git unstage a.txt
$ git st
## main
 M a.txt

$ git aliases
alias.st status -sb
alias.sw switch
alias.br branch
(中略)
alias.gone !git fetch -p && git branch -vv | awk '/: gone]/{print $1}'

alias の先頭に ! を付けると、シェルのコマンドとして実行されます(パイプや && が使えます)。.gitconfig に直接書くときは、\ を \\ と書く点に注意してください(aliases の例)。log の format 指定子や alias の作り方の詳細は、git log のオプション一覧の記事で扱っています。

設定の確認と削除(--get・--unset)

値の確認は --get、削除は --unset です。 終了コードも決まっているので、スクリプトで判定に使えます。

$ git config --get pull.rebase
true

$ git config --get core.pager; echo exit=$?
exit=1

$ git config --get-regexp '^rebase\.'
rebase.autostash true
rebase.autosquash true
rebase.updaterefs true

$ git config --default 'less -R' --get core.pager
less -R

キー名は大文字・小文字を区別しないため、表示は小文字になります(autoStash → autostash)。--default は、未設定のときに返す値を指定します。

複数の値を持つキー

$ git config --global --add include.path ~/.gitconfig-a
$ git config --global --add include.path ~/.gitconfig-b
$ git config --get include.path
~/.gitconfig-b
$ git config --get-all include.path
~/.gitconfig-a
~/.gitconfig-b

$ git config --global --unset include.path; echo exit=$?
warning: include.path has multiple values
exit=5
$ git config --global --unset-all include.path; echo exit=$?
exit=0

値が複数あるキーは --unset では消えず、--unset-all を使います。

削除とエラー

$ git config --global --unset diff.colorMoved
$ git config --global --unset diff.colorMoved; echo exit=$?
exit=5

$ git config --global --remove-section tag
$ git config --get tag.sort; echo exit=$?
exit=1

$ git config --global fetch.prune maybe
$ git config --type=bool fetch.prune
fatal: bad boolean config value 'maybe' for 'fetch.prune'
終了コード 意味(検証で出たもの)
0 成功
1 キーが見つからない(--get)
5 消すキーがない、または値が複数ある(--unset)

--type=bool を付けると、yes・on・1 なども true にそろえて返し、真偽値として読めない値はエラーで知らせてくれます。

新しい書き方(Git 2.46 以降)

Git 2.46 から、git config get・git config set・git config unset・git config list のようなサブコマンド形式が加わりました。従来の --get や --unset もそのまま使えます。この記事の検証環境(2.43)ではサブコマンド形式は使えず、error: key does not contain a section: get と表示されました。 2.46 以降の動きは公式ドキュメントで確認してください。

よくある質問

Q. --global の設定ファイルはどこにありますか? A. 通常は ~/.gitconfig です。~/.config/git/config を使うこともできます。git config --global --list --show-origin で実際のパスが表示されます。

Q. 設定したのに反映されません。 A. git config --show-origin --show-scope キー で、どの範囲の値が使われているかを確認します。local(.git/config)に同じキーがあると global より優先されます。エディタは環境変数 GIT_EDITOR も優先されます。

Q. alias で既存のコマンド名(例:status)を上書きできますか? A. できません。Git の組み込みコマンドと同じ名前の alias は無視されます。st のように別の名前を付けます。

Q. pull.rebase と pull.ff はどちらを設定すればよいですか? A. 履歴を一直線にしたいなら pull.rebase true、分岐したときは自分で判断したいなら pull.ff only が向いています。両方設定した場合は、pull.rebase が true なら rebase が使われます。

まとめ

  • 設定は system → global → local → worktree → -c の順に読まれ、あとのものが優先される
  • 困ったら git config --list --show-origin --show-scope で「どこの設定か」を確かめる
  • まず入れたいのは init.defaultBranch・push.autoSetupRemote・pull.rebase・fetch.prune・merge.conflictStyle zdiff3
  • rerere・autoStash・branch.sort・commit.verbose・help.autocorrect prompt で日々の操作が楽になる
  • diff.algorithm histogram は好みで。差分を比べてから決める
  • includeIf は末尾の / を忘れず、ファイルの最後に書く
  • 確認は --get/--get-all、削除は --unset/--unset-all/--remove-section

本記事の内容は、ご自由にお使いください。
ご利用の際は、出典として本ページへのリンクを記載いただけますようお願いします。

(記載例)出典:株式会社RJC「git config設定一覧とおすすめalias|最新Gitで入れるべき推奨値」

株式会社RJCでは、Git の設定を工夫して開発をなめらかにする方法を仲間と学び合っています。こうした知識を共有しながら、日々技術を磨いています。

株式会社RJC ― SI事業・SES事業・AI駆動開発。RJCは一緒に成長を楽しめる会社です。

WE ARE HIRING

RJCで一緒に開発しながら、
成長を楽しみませんか?

RJCは、Web・モバイル・AIを活用した開発プロジェクトで、テックリードやPM・PMOも活躍するシステム開発会社です。会社を知る、待遇を確かめる、話を聞いてみる。気になるところ見てみてください!

  • 127日年間休日
  • 12時間平均残業時間
  • 毎日ガチャ遊びココロも大切にする福利厚生。アマギフなどの賞品ラインナップ!

ほかにも、チケットレストラン、書籍読み放題、2年ごとの慰労報奨(休暇 or 金一封)、11期連続の黒字決算。

ABOUT RJC RJCがどんな会社か知る 考え方、研修、働き方、福利厚生、社員の前職まで。RJCのことが丸わかり! RJC丸わかりページへ JOB DESCRIPTION 仕事内容・待遇を見てみる 仕事内容、給与・待遇、選考の流れ。経験者も未経験も!応募前に知りたいこと、まとめました! 募集要項を見る ENTRY エントリーする エントリーは1〜2分・履歴書不要です。まずは話を聞いてみたい、という方でも歓迎です! エントリーフォームへ

RJCで一緒に開発しながら、 成長を楽しみませんか?