1

私がレポを作ったとしましょう

cd repo1
git init
git config user.name "Jack"
git config user.email jack@hill.com

それから私は別のものを作ります

cd ../repo2
git init
git config --global user.name "Jill"
git config --global user.email jill@hill.com

repo1で私はジャックまたはジルになりますか?これらの2つのステップが逆の順序で実行された場合、私はrepo1のジャックになると思いますか?

4

1 に答える 1

3

コマンドを実行する順序に関係なく、ジャックインrepo1とジルインになります。マニュアルページrepo2から:git config

   If not set explicitly with --file, there are four files where git config will search for configuration options:

   $GIT_DIR/config
       Repository specific configuration file.

   ~/.gitconfig
       User-specific configuration file. Also called "global" configuration file.

   $XDG_CONFIG_HOME/git/config
       Second user-specific configuration file. If $XDG_CONFIG_HOME is not set or empty, $HOME/.config/git/config will be used. Any single-valued variable
       set in this file will be overwritten by whatever is in ~/.gitconfig. It is a good idea not to create this file if you sometimes use older versions of
       Git, as support for this file was added fairly recently.

   $(prefix)/etc/gitconfig
       System-wide configuration file.

Gitはこれらのファイルをこの順序でロードします。ローカルリポジトリの、、.git/config~/.gitconfig優先されます。これは優先されます。これは優先されます。$HOME/.config/git/configこれは優先され/etc/gitconfigます。さらに:

All writing options will per default write to the repository specific configuration file. Note that this also affects options like --replace-all and
--unset. git config will only ever change one file at a time.

フラグはシステム上で--globalすべて変更されるわけではなく.git/config、ただ~/.gitconfig

于 2012-08-16T11:56:29.360 に答える