Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

It’s simply is because ~ is shorthand that expands to the absolute path of the current user’s home directory.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top