1

I have two network adapters, each connect to different network. I have two git repository too, When I push my commit to one repo, something like

git push -u origin developer

I have to disable other network adapter

enter image description here

Is there a way to run git or command line bind to specific network adapter not need disable network adapter, something like git remote -v --network 10.1.2.3 ?

TienThanh
  • 34
  • 1
  • 13
  • 1
    No. This must be resolved at the network routing level. – phd Jan 19 '21 at 05:09
  • Oh, thank you. So, I have to write a command to change the network routing level then use git. Do you know the command to change the network routing level? – TienThanh Jan 19 '21 at 06:06

1 Answers1

1

Since this is not supported by Git itself, as commented, you would need to use the netsh command in order to disable/enable a network adapter from command line

You can see one example in this question or in this script:

@netsh interface set interface name="LAN1" admin=disabled
@netsh interface set interface name="LAN0" admin=Enabled

The idea for this script would be to detect which one is enabled and disabling it, enabling the other: the script would act as a switch and could be called as part of a git alias.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250