Reputation: 137
I know I can use git remote set-url origin
to change the URL of a remote repo? On my Linux machine I run something like
git remote set-url origin ~/projects/test.git
but git
always changes the relative path into an absolute one such as /home/user/projects/test.git
.
Can I prevent this behaviour?
Upvotes: 0
Views: 5685
Reputation: 4810
The ~
is probably expanded by your shell in that command (for example, if you are using bash see 'tilde expansion' in http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_04.html).
You might get what you want by quoting the url with single quotes like this: git remote set-url origin '~/projects/test.git'
.
Edit: I don't think having a tilde path as a remote is a good idea though. I'm not sure how the expansion is made. As mentioned in the comments, git is a mix of c programs and bash scripts. This could make the tilde expansion fail under certain command and work for others.
Upvotes: 1
Reputation: 136
It’s simply is because ~
is shorthand that expands to the absolute path of the current user’s home directory.
Upvotes: 0