git config
git
書き方
git config [--global] <key> [<value>]gitの設定を読み書きします。--globalを付けないと今のリポジトリにしか書かれず、新しくクローンした所には引き継がれません。
よく使うオプション
| オプション | 意味 |
|---|---|
| --global | write to ~/.gitconfig for every repository |
| --local | write to .git/config, the default |
| --list --show-origin | print every setting and the file it came from |
| --get <key> | print one value |
| --unset <key> | delete one setting |
| -e | open the config file in your editor |
例
git config --global user.email "me@example.com"sets the address every future commit is signed with
git config --global init.defaultBranch mainnew repositories start on main instead of master
git config --list --show-originshows which file each setting comes from
取り消しに何通りもあるのが混乱のもとです — ブランチの指す先を動かすのと、打ち消すコミットを積むのは別です。
読み方
- 角括弧 [ ] は省いてよい部分です。
- 三点 … は複数並べられるという意味です。
- オプションは大文字小文字を区別します — -r と -R が別物のコマンドもあります。
よくある質問
Q. git config は何をしますか。
gitの設定を読み書きします。--globalを付けないと今のリポジトリにしか書かれず、新しくクローンした所には引き継がれません。
Q. どう打ちますか。
git config [--global] <key> [<value>] — 角括弧は省いてよい部分です。
Q. よく使うオプションはいくつですか。
ここにまとめたのは6個です。全部は man git にあります。このコマンドはgitの仲間です。
関連するコマンド
man ページ: man git-config