Git for Windowsでアカウントをワーキングディレクトリで切り替える
そんな時は「
.gitconfig
」を拡張しましょう。まずは作業するプロジェクトで使うGitユーザー、メールアドレスを設定したファイルを作成します。
ファイル名はわかりやすいように「
.gitconfig_プロジェクト名
」とかにしときましょう。
[user]
name = MyCompony-Taro
email = taro@example.co.jp
%USERPROFILE%\.gitconfig
」を編集します。設定を切り替えたいディレクトリへの参照とその時適用したい設定ファイルの参照を末尾に追記します。
[user]
name = Taro
email = taro@example.com
~~~省略~~~
[includeIf "gitdir:C:/Users/taro/myproject/"]
path = "C:/Users/taro/.gitconfig_myproject"
これで設定は終わりです。
ディレクトリを移動すると設定が切り替わることが確認できます。
C:\Users\taro>git config user.name
Taro
C:\Users\taro>cd myproject
C:\Users\taro\myproject>git config user.name
MyCompony-Taro
ディスカッション
コメント一覧
まだ、コメントがありません