git push and git pull hanged (using SSH url).
- Enable tracing in git to check what's wrong:
$ GIT_TRACE=1 git push
trace: built-in: git push
trace: run_command: unset GIT_PREFIX; ssh git@github.com 'git-receive-pack '\''sohang3112/machine-learning-practice.git'\'''
trace: start_command: /usr/bin/ssh git@github.com 'git-receive-pack '\''username/repo.git'\'''- We're stuck at ssh connection to github, so let's check that seperately (enabling verbose mode for debugging):
$ ssh -vvv -t git@github.com
OpenSSH_9.6p1, OpenSSL 3.2.2 4 Jun 2024
debug1: Reading configuration data /home/sohang/.ssh/config
...
debug1: Connecting to github.com [64:ff9b::14cf:4952] port 22- SSH hanged while connecting to IPv6 address of Github, so let's try IPv4 instead:
$ ssh -o AddressFamily=inet -T git@github.com
PTY allocation request failed on channel 0
Hi username! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.Using IPv4 for SSH connection worked (didn't hang)! Now let's set this option in SSH config so that it always uses IPv4 only for Github:
# add this in ~/.ssh/config file
Host github.com
AddressFamily inet
Now git push and git pull work without hanging!