While marked answer is 100% correct I use a bit different approach. For ssh connections using OpenSSH client I utilze ProxyCommand for *.onion sites in the following way:
ProxyCommand socat STDIO SOCKS4A:<tor socks hostname or IP>:%h:%p,socksport=9050
This should also be the only change needed for git ssh ...
torsocks is the way to go. You may need to install it separately from Tor if it is not installed automatically.
Make sure Tor is running: systemctl status tor
Run your command through torsocks: torsock git pull or torsocks ssh abcxyz.onion
Another option is to run torsocks --shell. This will make all commands in that shell automatically run through Tor. ...