Have a look at ssh's ProxyCommand. By adding a section into your ssh config file like
Host server2
ProxyCommand ssh -q server1 nc -q0 %h 22
you should be able to use git with a repo an server2. Note: This requires nc being available on server1.
This solution makes accessing server2 through ssh, e.g. with git, transparent as if it was directly accessible.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…