Reputation: 6715
Is it possible to change the default/root directory of where git looks for projects so you can clone a project like this:
git clone [email protected]:project.git
rather than like this:
git clone [email protected]:/var/www/html/project.git
I've seen git --git-dir=<path>
in the help page but it seems that it only takes effect for that particular command rather than being a global setting - and that's even if it does what I want it to do.
Can anyone help?
Upvotes: 1
Views: 1582
Reputation: 97282
Well, before all other: you use scp-style notation, standard URLs will be better for communication
Back to question: Yes, you can do it
if you want to use a different format for them (such that the URLs you use will be rewritten into URLs that work), you can create a configuration section of the form:
[url "<actual url base>"]
insteadOf = <other url base>
in your example it will be
[url "myserver.com:/var/www/html/"]
insteadOf = myserver.com
or even
[url "[email protected]:/var/www/html/"]
insteadOf = myserver:
for using URL myserver:project.git
Upvotes: 0
Reputation: 12263
When you're using ssh path, it always start in given user's home directory. So for the example in the question to work, all you have to do is set HOME directory of git
user to /var/www/html
.
Upvotes: 2
Reputation: 8491
When using the git protocol, you can set it on the server by giving git daemon
the --base-path
option.
Upvotes: 0