When at home, git fetch origin master
should connect over ssh to git@192.168.xx.xx
.
When on the road, git fetch origin master
should connect over ssh to git@xxx.linkpc.net
.
Possible Solutions
- Having multiple remotes for the same repository/branch works but git tracks multiple heads unnecessarily. This solution just messes with the beauty.
- Assigning a hostname to remote and comment/uncomment
/etc/hosts
entries to delegate ips is a nice solution but includes sudoing and entering the root password which is kind of tedious. - A per user hosts file is out of the question.
- Writing a script that each time the
origin
is called will delegate the correct ip, is ideal. - Writing a script that will be executed as root each time a user calls it, seems to be a marginally fair solution.
Question
How could someone tackle with this issue using a solution that -by all means- shall not be considered "of a hackish character"?