'Git global config for specific repositories?
Meaning, having something like a per repo section [repo_url] that overrides global(not for a specific repo) options.
[core]
filemode = false
editor = notepad
[repo "example.com/repo1.git"]
[core]
filemode = true
# editor = notepad
[repo "example.com/repo2.git"]
[core]
editor = vim
# filemode = false
Is possible in git?
Note: I'm making a lot of clones(git clone) of repos which I would specify in such a global config
Solution 1:[1]
local and conditional configs will work for your title question, but there's no condition based on what's in a repo's remote urls. Considering local clones that idea immediately starts looking fragile and confusing.
It might make more sense to have a condition based on whether or not a particular commit exists in a repository, but there's no indication in your question what the motive is here. If you'll explain what situation you're in that prompts this question, it might get more helpful answers.
Solution 2:[2]
Solution: includeIf (big thanks to @phd)
global config
[core]
filemode = false
editor = notepad
[includeIf "gitdir/i:repo1/"]
path = path_to_repo1_git_config
[includeIf "gitdir/i:repo2/"]
path = path_to_repo2_git_config
repo1_git_config
[core]
filemode = true
repo2_git_config
[core]
editor = vim
That way any repository to which repo1/repo2 is a parent(not immediate) directory will have respective config included. Note the slash at the end of each `includeIf (read docs).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | jthill |
| Solution 2 | Hrisip |
