I have a git repo that requires a number of atypical settings. I'd like to set it up so that when people clone my repo and work with branches they don't have to follow a list of steps. But I also don't want to get in the way of dealing with other repos they work with, possibly even in the same project.
I want
git config remote.<remote>.push HEAD:/refs/for/something
git config branch.<branch>.merge refs/head/something
(where branch's remote is<remote>
)
Is there some way to configure this so that just by cloning the repo everything is set up properly?
There isn't. That's intentional. Your repo is yours. You have complete control over what goes on in it, nothing happens until you explicitly act.
To help others set up their repos correctly for your project easiest might be to provide a ~repo/config setup~ script they can run with or without looking at what it's going to do.
Another thing you could do, though it looks a bit problematic for your needs here, is to set up the default repo template at your site with the configs you're suggesting. That way people at your site will get your desired setup by default. Anybody who knows enough to have their own default will have no trouble at all running a repo setup script.
About as close as I can get to making the setup brainless is to provide a custom template, possibly by a simple frontender (e.g. complete contents git clone --template=path/to/yourproject/template "$@"
).
来源:https://stackoverflow.com/questions/26786778/can-i-specify-git-config-values-in-a-repo