gogma
gogma

Reputation: 1

Single git remote repository with multiple IP address

I have a git bare repository as a remote on a server with 2 network interfaces, whose IP address are 192.168.x.x and 223.x.x.x respectively. I have a signle git project on this single remote origin. Inside the lab this remote can only be accessed via 192.168.x.x (CISCO hairpin disabled), and vice versa (which of course).

Can this remote origin be accessed via like one "git push" or one "git pull" regardless of what network my laptop is on?

On my laptop I tried,

git remote add origin ssh://[email protected]/home/gogma/git/prj.git
git remote set-url --add origin ssh://[email protected]/home/gogma/git/prj.git

didn't seem to work. no issues with ssh itself.

This is what I have:

$ git remote -v
origin  ssh://[email protected]/home/gogma/git/prj.git (fetch)
origin  ssh://[email protected]/home/gogma/git/prj.git (push)
origin  ssh://[email protected]/home/gogma/git/prj.git (push)
$ 

Upvotes: 0

Views: 530

Answers (1)

VonC
VonC

Reputation: 1329512

That would fail on one, and succeed on the other origin psuhURL entry entry on every git push/pull/clone.

I would rather clone it twice:

Depending on the network, my .bashrc would symlink the right folder to a common path.

ln -s /path/to/network1/project /path/to/project
ln -s /path/to/network2/project /path/to/project

Each one has a otherNetwork remote entry in order for you to do a git fetch otherNetwork when switching /path/to/project, getting the latest commits you did from one folder into the other.

Upvotes: 0

Related Questions