Git push hangs when pushing to Github?

163,305

Solution 1

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

This worked for me. It may take 3-5 secs for the prompt to appear just enter your login credentials and you are good to go.

Solution 2

Restart your ssh agent!

killall ssh-agent; eval `ssh-agent`

Solution 3

Try creating a script like ~/sshv.sh that will show you what ssh is up to:

#!/bin/bash
ssh -vvv "$@"

Allow execution of the ~/sshv.sh file for the owner of the file:

chmod u+x ~/sshv.sh

Then invoke your git push with:

GIT_SSH=~/sshv.sh git push ...

In my case, this helped me figure out that I was using ssh shared connections that needed to be closed, so I killed those ssh processes and it started working.

Solution 4

Try GIT_CURL_VERBOSE=1 git push

...Your problem may occur due to proxy settings, for instance if git is trying to reach github.com via a proxy server and the proxy is not responding.

With GIT_CURL_VERBOSE=1 it will show the target IP address and some information. You can compare this IP address with the output of the command: host www.github.com. If these IPs are different then you can set https_proxy="" and try again.

Solution 5

Using "Command Prompt" (cmd) instead of git bash for initial push resolved the hang up for me. Since then I use git bash without any issues.

Share:
163,305

Related videos on Youtube

Matt Singer
Author by

Matt Singer

Entrepreneur, Marketing, Sales, Internet, Tech, Management, Business Startup & Development, Team Building Aspiring Ruby on Rails Developer, beginner, learning. Building BizRoller.com with Ruby on Rails

Updated on April 24, 2022

Comments

  • Matt Singer
    Matt Singer about 2 years

    Git push hangs everytime I try to push to github. I am using Cygwin and Windows 7. Git functions fine locally tracking branches, providing status, setting global user.name and user.email and allowing commits.

    I'm still new and learning.

    I enter git push , git push origin master or git push -u origin master and I get nothing but a blank line requiring me to ctl-c to get the prompt back.

    ssh-keygen -t rsa -C "[email protected]" asks me for a file name and hangs

    git push heroku master hangs

    $ git status returns On branch master nothing to commit, working directory clean

    $ git pull returns Already up to date

    $ git remote -v returns:

    heroku  [email protected]:myherokusite.git (fetch)
    
    heroku  [email protected]:myherokusite.git (push) origin  
    
    https://github.com/gitusername/appname.git (fetch) origin  
    
    https://github.com/gitusername/appname.git (push)
    
    or the correct ssh remote settings are returned when trying this with ssh
    

    Updated: Using the SSH url [email protected]:gitusername/gitrepo.git also hangs

    git remote set-url origin https://github.com/gitusername/appname.git is correct

    Updated: I can see the git processes running in Windows Task Manager while it hangs.

    I've tried:

    Using different internet connection locations

    switching between https and ssh and it hangs

    Uninstalled git. Reinstalled from: https://code.google.com/p/msysgit/downloads/list

    Uninstalled git. Installed Cygwin's git

    Uninstalled git. Installed Github for Windows GUI app and it I WAS able to push. But this app has limited functionality, forces me out of my Cygwin window into another app which then forces me into a Windows command prompt for complete functionality which I thought I had escaped by using Cygwin.

    Spent many, many hours trying to resolve this, it worked faultlessly before, thanks.

    UPDATE 4/2014: I rebuilt my entire machine Win 7, Cygwin etc and all is now working fine

    • Guillaume Darmont
      Guillaume Darmont almost 11 years
      Are you behind a firewall or a proxy ?
    • Matt Singer
      Matt Singer almost 11 years
      I tried different internet connections without success, yes I have anti-virus which had never caused a problem previously. No proxy.
    • skilbjo
      skilbjo almost 11 years
      Any luck? I am encountering the same issue with cygwin. A fix: if I use the native windows shell (cmd.exe) however, git push origin master works fine.
    • Michael Trojanek
      Michael Trojanek over 7 years
      For the sake of completeness (sometimes problems like this are not as complicated as they might seem): Having a non-existing remote repository configured can also result in this behavior - I recently found out by accidentally changing my origin's URL to githu.com.
    • ktamas
      ktamas over 4 years
      For me restarting computer helped.
    • PetMarion
      PetMarion almost 4 years
      Another reason might be that the git server has reached its resource limits, and there's nothing wrong with your local git setup.
    • erwaman
      erwaman over 3 years
      When this happens for me, I've found deleting ~/.ssh/[email protected]:22.connection fixes the issue (I have some settings in ~/.ssh/config to persist connections).
    • 42n4
      42n4 about 3 years
      I had to logout from VPN.
  • Allan Nienhuis
    Allan Nienhuis about 10 years
    that was very helpful for me - Thanks!
  • hello_there_andy
    hello_there_andy almost 9 years
    I ran this and now it keeps saying error: cannot run git-gui--askpass: No such file or directory, could you advise me on how to reverse this please?
  • markphd
    markphd almost 9 years
    @hello_there_andy this may help you.
  • Yan King Yin
    Yan King Yin over 8 years
    how do you restart ssh-agent? I'm using linux
  • ashes999
    ashes999 over 7 years
    I restarted ssh-agent by terminating the ssh-agent.exe process. On windows, you can use ps -ef | grep ssh to find it, and kill to exterminate it. Restarting is probably safer. @YanKingYin
  • Drew
    Drew over 7 years
    @Yan King Yin Nov, I'm not sure about linux, but on mac I've done it using LaunchControl GUI or running: sudo launchctl stop /System/Library/LaunchAgents/org.openbsd.ssh-agent and sudo launchctl start /System/Library/LaunchAgents/org.openbsd.ssh-agent... Pretty sure linux should have something similar to bsd launchd… Like init-v or systemd way of stopping/starting agents/daemons… You could try this spell: killall ssh-agent; eval $(ssh-agent). Let me know if it's working for you.
  • Luka Ramishvili
    Luka Ramishvili over 6 years
    This was the issue in my case. Fortunately, git push hanged for multiple remotes so I knew there wasn't a problem with the remote's server.
  • AlwaysLearning
    AlwaysLearning over 5 years
    This line did nothing for me. Empty output.
  • Jérémie Lesage
    Jérémie Lesage over 5 years
    For debug, it's simpler to add LogLevel DEBUG3 in ~/.ssh/config
  • Sebasthian Ogalde
    Sebasthian Ogalde about 5 years
    After running this line, the problem is not solved and now when pushing, git keeps saying error: cannot run git-gui--askpass: No such file or directory. The solution added by @forloop helped me to reverse it.
  • Matteljay
    Matteljay over 4 years
    I tried git push -u origin master --verbose but even that didn't show anything useful. After reading this solution I copied the whole ~/.ssh from my older Linux pc to my Windows Cygwin64 home/user folder, worked like a charm.
  • EMon
    EMon over 4 years
    That's the one!
  • Albert Mosiałek
    Albert Mosiałek about 4 years
    Thank you. In my case it was enough to restart sshd: sudo systemctl restart sshd
  • Martin DeMello
    Martin DeMello almost 4 years
    thanks, just ran into this problem and it was my ssh agent hanging too! would have taken me ages to figure it out myself
  • colmjude
    colmjude almost 4 years
    This worked for me too when my terminal was hanging indefinitely
  • thienkhoi tran
    thienkhoi tran over 3 years
    This should be the answer, I'm using ubuntu 20 (2 years since your posted comment) and facing the same issue, I've reinstalled this and it's working now,
  • jones
    jones over 3 years
    it seems to happen again and again though :( this command helps sometimes, other times it will still halt. something's not right
  • jburtondev
    jburtondev over 3 years
    Yes that doesn't sound right. Perhaps you should put this command in your bash profile so every time you load the terminal it will run it.
  • Timo
    Timo over 3 years
    After Adding logLevel Debug3, is ssh reload needed? I do not think so due to client side.
  • Timo
    Timo over 3 years
    GIT_SSH=~/sshv.sh git push ...: Is this a GIT var and also a cmd to run/execute? Why is the var defined and not the script run with the git push param. I tested this: ssh -vvv 'git push', but no avail.
  • Kushan Gunasekera
    Kushan Gunasekera over 3 years
    This is working fine in Ubuntu 20.04, thank you @gustavz
  • stasdeep
    stasdeep over 3 years
    That was the issue for me, thanks a lot! After disconnecting from the VPN I've managed to push.
  • Stefan
    Stefan almost 3 years
    Where is that sign in prompt?
  • Keshav Gupta
    Keshav Gupta almost 3 years
    I did not expect this to work! thanks for the tip
  • devnull69
    devnull69 over 2 years
    Oh my god ... this worked. I wasn't expecting this
  • blaylockbk
    blaylockbk over 2 years
    I killed all tasks and now git push works. 🤷🏻‍♂️
  • jburtondev
    jburtondev over 2 years
    @blaylockbk lol
  • Flip
    Flip over 2 years
    Worked perfectly fine for me. I didn't even have to enter any credentials.
  • Dave Pritlove
    Dave Pritlove about 2 years
    This worked for me. Terminal on Mac was hanging after listing Enumerating... Counting... Writing... Total... but this killall freed it up.
  • Jomy
    Jomy about 2 years
    That's the one for me
  • user212514
    user212514 about 2 years
    I ended up setting the buffer for the local repo only, but it solved my issue git config --local http.postBuffer 524288000
  • rufatZZ
    rufatZZ about 2 years
    THIS IS THE ONE!
  • aRyhan
    aRyhan almost 2 years
    2022 and this still works!