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.