You can pass configuration variables to git through the environment which will let you be tricky and do what you want. This will only work if you don't have GIT_CONFIG set. In your shell environment's startup scripts you could setup something like:
GIT_ORIGIN_REMOTE=git://github.com/gitster/git.git
GIT_CONFIG_PARAMETERS="'remote.origin.url=${GIT_ORIGIN_REMOTE}'"
Make sure you have removed the remote origin url config line in .git/config. This will cause all operations that use the origin
remote to operate with git://github.com/gitster/git.git
. Now all you have to do is change the GIT_ORIGIN_REMOTE in your startup environment script if your directory changes. Notice the format of GIT_CONFIG_PARAMETERS, it is important that your config options are single quoted. If you want to pass more than one configuration option to Git from the environment follow the form of:
GIT_CONFIG_PARAMETERS="'<config_variable>=<value>' '<config_variable>=<value>'"
You should be able to use this info to setup the environment how you see fit. I haven't actually seen this documented, just found it through the source, so YMMV depending on the version of Git you're using. Ref: Git Tokenizing Code & Git Parsing Code