Git Push Hangs

Sometimes developers go through a situation when they want to push some changes to the repository by using the command git push, and after applying this command, they come to know that their system has started hanging, and they feel clueless about this situation.

This situation occurs when the developers have a personal computer with very old technology, and their memory does not have enough support to manage these actions.

One of the proper and long-term solutions to this problem is to upgrade the personal computer or the system and use the Git commands without any issues.

This tutorial will help us solve the hanging problem when a git push is applied to huge files using the Git command.

Git Push Hangs Solution

Developers usually face these problems due to the colossal size, which requires much time to upload. That’s why the file shouldn’t be added in the push command in the first run.

git config --global http.postBuffer 524288000

The following commands will only apply to ssh.

  1. Here, we have to make a script like ~/sshv.sh.
```bash
#!/bin/bash
ssh -vvv "$@"
```
  1. Then, we have to add permissions through the following command.

    chmod u+x ~/sshv.sh
    
  2. Then push it to the repo where you were pushing the code.

    GIT_SSH=~/sshv.sh git push <rest of your command>`
    

Use Git askpass

We can also solve this hanging issue using the following command line script.

git config --global core.askpass "git-gui--askpass"

The above command is mostly used when the command is not getting the first argument to the node correctly, causing the hanging problem in the git push command in Git.

Restart SSH Agent

If the problem is still not solved, then the final solution to this issue is to restart the SSH agent by using the following command in Git.

killall ssh-agent; eval `ssh-agent`

These SSH keys are mostly saved at the location ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub. We can also transfer these keys to another location if that issue still occurs in the future.

But the above command will reset your SSH-related issues, and the hanging issue will eventually be solved.

Related Article - Git Push

  • Make an Initial Push to a Remote Repository With Git
  • Push a Specific Commit to a Remote Repository
  • Git Push --force-with-lease vs Git Push --force