うさぎ小屋(仮)

📅  2021-12-19

githubのOrganization別に別々のgitconfigを設定して利用する


以下のように、 .gitconfigを設定します。

[user]
  name = amasok
  email = xxxxx@gmail.com
[includeIf "gitdir:~/works/a_project/"]
	path = .gitconfig_a_project

上記の設定では、includeIf で ~/works/a_project/配下でgit clone したリポジトリは.gitconfig_a_projectの設定が適用されます。

以下、.gitconfig_a_projectの設定

[user]
  name = a_amasok
  email = a.amasok@a.com
[url "https://ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:x-oauth-basic@github.com/"]
	insteadOf = https://github.com/

上記のように設定することで、Personal access tokens を設定することで別のgithubのアカウントでも利用が可能です。