Git push hangs when pushing to Github?
Asked Answered
G

42

187

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

Ger answered 3/6, 2013 at 21:29 Comment(10)
Are you behind a firewall or a proxy ?Simian
I tried different internet connections without success, yes I have anti-virus which had never caused a problem previously. No proxy.Ger
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.Johny
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.Sousaphone
For me restarting computer helped.Arius
Another reason might be that the git server has reached its resource limits, and there's nothing wrong with your local git setup.Larrigan
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).Slipon
I had to logout from VPN.Davila
Funny, cos I had this issue and had to log into VPN to solve it... weird.Monmouthshire
I've encountered this issue when doing some local website development. I was running a local server to test the content, and git push hung until I remembered to stop the local server process. All other git commands worked without issue throughout development.Uyekawa
A
195

Restart your ssh agent!

killall ssh-agent; eval `ssh-agent`
Angelicangelica answered 20/11, 2019 at 19:39 Comment(12)
This worked for me too when my terminal was hanging indefinitelyAmalamalbena
it seems to happen again and again though :( this command helps sometimes, other times it will still halt. something's not rightEpp
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.Angelicangelica
I killed all tasks and now git push works. 🤷🏻‍♂️Han
@Han lolAngelicangelica
This worked for me. Terminal on Mac was hanging after listing Enumerating... Counting... Writing... Total... but this killall freed it up.Colobus
THIS IS THE ONE!Canaille
2022 and this still works!Hedonics
Make sure to do this in every terminal you have open--in which you have tried to push.Ad
THIS IS THE ONEEEEEEEEEEEE!!!!!Detach
If you have large files you might have to enable Git LFS: docs.github.com/en/repositories/working-with-files/…Hill
2023 and this worked for me immediately. Control + C to kill the hang after showing me: "Total 398 (delta 156)..." Then did the command provided above, tried to push again immediately after and it worked. Apple M2, Ventura 13.4.1Rosebay
R
93
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.

Redpencil answered 6/10, 2013 at 2:22 Comment(6)
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?Mullens
@Mullens this may help you.Redpencil
This line did nothing for me. Empty output.Lavone
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.Garygarza
Worked perfectly fine for me. I didn't even have to enter any credentials.Henze
If using git on command line only, such as via remote SSH, I expect this solution is not applicable.Inhabitancy
V
50

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.

Vaudois answered 16/9, 2013 at 17:52 Comment(6)
For debug, it's simpler to add LogLevel DEBUG3 in ~/.ssh/configAlurta
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.Shane
Thank you. In my case it was enough to restart sshd: sudo systemctl restart sshdPettway
After Adding logLevel Debug3, is ssh reload needed? I do not think so due to client side.Gonad
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.Gonad
This was a good hint: I just did ps aux | grep ssh then killed anything that came up. Then push worked after that!Puffy
D
45

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.

Denature answered 9/6, 2013 at 19:27 Comment(1)
That was the issue for me, thanks a lot! After disconnecting from the VPN I've managed to push.Heinrick
A
30

I had the same problem with absolutely same symptoms… I was about to rebuild my whole system in my despair)). I also tried git config --global core.askpass "git-gui--askpass", but it didn't work.

The solution was to restart the ssh-agent:

launchctl stop /System/Library/LaunchAgents/org.openbsd.ssh-agent 

launchctl start /System/Library/LaunchAgents/org.openbsd.ssh-agent

If needed, prefix these with sudo.

Avivah answered 26/9, 2015 at 1:52 Comment(6)
how do you restart ssh-agent? I'm using linuxNerveracking
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. @YanKingYinHymenopteran
@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.Avivah
thanks, just ran into this problem and it was my ssh agent hanging too! would have taken me ages to figure it out myselfDejecta
This does work for me but I have to run both commands before every single push.Gatehouse
On my Mac I needed to use: launchctl stop /System/Library/LaunchAgents/com.openssh.ssh-agent.plist launchctl start /System/Library/LaunchAgents/com.openssh.ssh-agent.plistFarrish
P
28
  1. Had the same problem. Was a little bit confused but the thing was I had make a git init --bare on root, that means that you won't be able to push because of you don't have any rights. Instead make a new User or in my case I used Pi User and made git init --bare there, which then later on it worked.

  2. git config --global http.postBuffer 524288000

Maximum size in bytes of the buffer used by smart HTTP transports when POSTing data to the remote system. For requests larger than this buffer size, HTTP/1.1 and Transfer-Encoding: chunked is used to avoid creating a massive pack file locally. Default is 1 MiB, which is sufficient for most requests.

Pester answered 22/2, 2019 at 16:25 Comment(3)
I ended up setting the buffer for the local repo only, but it solved my issue git config --local http.postBuffer 524288000Virulence
Thanks a lot! If somebody has this problem with a somewhat larger repo (like a monorepo) try this solution first.Acariasis
This worked for my repo with larger files, I added several mp3 files between 5 and 20MB. I just updated the config for the local repoPreterit
M
23

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.

Meaning answered 19/6, 2021 at 17:12 Comment(3)
I did not expect this to work! thanks for the tipConsummation
Oh my god ... this worked. I wasn't expecting thisInflated
Worked for me. I thought i'd used Git Bash before without problems, but maybe not -- couldn't even copy/paste into it without drama -- I'm on Windows. I used to use UnxTools (spelling correct).Fowkes
K
23

In my case, the issue was the https seems to be no longer supported and I had to switch all my origins from the old https://github.com/username/myrepo to [email protected]:username/myrepo.git.

I did this with

git remote set-url origin [email protected]:username/myrepo.git
Keare answered 11/11, 2021 at 22:3 Comment(1)
That's the one for meWatchcase
T
14

I was struggling with this problem on a Mac. My solution was to kill all git processes using the following command:

killall git

Hope this helps someone!

Thetis answered 22/12, 2022 at 22:36 Comment(2)
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From ReviewConfessedly
This did it for me. I spent an hour trying to figure out what was wrong. I guess a stuck git process. Thanks a bunch.Dyanna
K
12

I had the same issue. Stop worrying and searching endless complicated solutions, just remove git and reinstall it.

sudo apt-get purge git
sudo apt-get autoremove
sudo apt-get install git

Thats it. It should work now

Kiwanis answered 10/1, 2018 at 11:12 Comment(4)
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,Scully
This is working fine in Ubuntu 20.04, thank you @KiwanisSoever
If you used a passphrase which was stored before you must save it again: ssh-agent bash && ssh-addBurgonet
I tried this and no change fwiw, ubuntu 22.04 via WSLSnowblind
A
6

Its worth checking if you are using the cygwin git or an external git (ie github).

If whereis git returns just /cygdrive/c/Program Files (x86)/Git/cmd/git.exe or similar its best to install the cygwin git package, this solved the problem for me.

Assemblyman answered 14/12, 2013 at 17:33 Comment(0)
P
6

For anyone experiencing this since 2021/08/13 and finding this question, it may be related to the recent auth policy changes on GitHub. They are no longer accepting username/password for authentication.

The solution is to set up ssh access or create a personal access token.

Photocell answered 17/8, 2021 at 20:59 Comment(1)
According to GitHub's suggestion, I set up Git Credential Manager which resolved my issue.Gill
W
6

I had this same issue today, all I did to resolve it was remove origin git remote remove origin and re-add it git remote add origin https://github.com/username/project.git then I was able to push successfully.

Whittington answered 4/12, 2021 at 17:56 Comment(0)
Z
5

This command solved it for me:

git fetch origin

Which updates your local repository with any changes from the remote repository, which can resolve conflicts that may be preventing your push from completing. After running git fetch, you can then run

 git push

to try pushing your changes to the remote repository again.

Zanthoxylum answered 8/2, 2023 at 9:19 Comment(1)
Solved it for me!Diathermy
H
4

I thought my Git windows screen was struck but actually a sign in prompt comes behind it.Check for it and enter your credentials and that's it.

Heilbronn answered 20/1, 2018 at 9:31 Comment(1)
Where is that sign in prompt?K
S
3

In my case a new public key on cPanel (my remote) was not yet authorized. My client was a new machine running Ubuntu 2020-04

git push origin

...worked, but prompted for the cPanel password.

I assume the git-gui process hung waiting for a password that I couldn't enter.

After authorizing my new key git-gui worked. It did prompt for the key store password.

Skidproof answered 5/3, 2021 at 1:4 Comment(0)
A
2

I just wanted to say that I'm having this issue on my AWS EC2 instances. I was trying to push from my EC2 instance itself, when I have it configured to only allow traffic in from the load balancer. I changed the rule to allow HTTP in from everywhere, but it still didn't fix the problem. Then I realized it's because my security groups are configured to not allow outbound traffic from my EC2 instances over HTTPS. I didn't have allow HTTPS inbound traffic to make it work, even though it's probably a good policy for you to have HTTPS available inbound.

Arsenopyrite answered 23/9, 2015 at 23:44 Comment(0)
T
2

This occurred for me when my computer's disk space was full. Delete some files & empty the trash to fix.

Therapeutic answered 15/12, 2015 at 16:11 Comment(1)
I add the same issue with my server (remote git repository) disk's space completely fullBoodle
C
2

Use Git CMD, not Cygwin Bash Terminal.

By using the Git CMD, my system was able to authenticate my information on GitHub. After that, using bash worked fine. I understand that there was some sort of authentication the program was trying to do, but couldn't do from the bash terminal for some reason. Although this answer is not comprehensive, it does get the job done.

Cacus answered 14/7, 2021 at 21:45 Comment(0)
P
2

Sometimes I have this hanging issue when pushing a new branch from Android Studio and it does not give an error message. Usually, if I do a simple fetch from main it will work afterwards.

Pons answered 28/3, 2022 at 18:52 Comment(0)
M
2

Sometimes not stuck. Maybe it will be pushing. You can check progress of your push by using this command.

git push --progress

See more about how to see git push progress: How can I know how much percentage of git push is complete?

Magnetometer answered 3/12, 2022 at 10:58 Comment(1)
If it is stuck you will not be able to use the command lineKarinkarina
G
1

I'm wondering if it's the same thing I had...

  1. Go into Putty
  2. Click on "Default Settings" in the Saved Sessions. Click Load
  3. Go to Connection -> SSH -> Bugs
  4. Set "Chokes on PuTTY's SSH-2 'winadj' requests" to On (instead of Auto)
  5. Go Back to Session in the treeview (top of the list)
  6. Click on "Default Settings" in the Saved Sessions box. Click Save.

This (almost verbatim) comes from :

https://tortoisegit.org/issue/1880

Galloping answered 3/4, 2014 at 11:12 Comment(0)
H
1

In my case the issue was there was some process that had locked my keychain access...

Force quit all other apps to make sure keychain access is not locked on your Mac

Hemoglobin answered 27/10, 2016 at 18:55 Comment(1)
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.Spinode
S
1

I'm new to this. I managed to solve my issue regarding the hanging git push command.

I recently installed git scm. In one of the installation options, I had selected to use git credential manager core. I assumed that it was installed automatically. But it looks like there was an error in that installation. I reinstalled git credential manager core from the website, and it works perfectly now.

Soundproof answered 20/6, 2021 at 13:19 Comment(0)
T
1

In my case git was trying to use Ipv6 instead of Ipv4 to authenticate github and my terminal was stuck here set_sock_tos: set socket 3 IPV6_TCLASS 0x48.

To solve this I added AddressFamily option to ~/.ssh/config

Host github.com
  Hostname github.com
  AddressFamily inet 
  IdentityFile ~/.ssh/id_rsa  

test command:

ssh -vT [email protected]

Tapia answered 22/4, 2022 at 16:20 Comment(0)
S
1
  • git reset HEAD^, that will do undo your commit
  • push again in separate commits
Sunn answered 22/3, 2023 at 6:42 Comment(0)
T
1

Increase Timeout Settings:

You can increase the timeout settings for Git to allow for longer operations. This can be done by setting the http.postBuffer and http.lowSpeedLimit configuration values:

git config --global http.postBuffer 524288000 # Set to a large value (e.g., 500 MB)
git config --global http.lowSpeedLimit 0
Tillfourd answered 4/10, 2023 at 16:40 Comment(1)
This is the only thing that worked from me among the several answers on this page.Incogitant
F
0

I also had an issue where git hangs on the "Writing objects" part on Windows 7 (using msysgit, the default windows client from git) and this is the first hit I got in google, so I will also post my answer here.

git config --global core.askpass "git-gui--askpass" did not work unfotunately, but after some researching I found the tip on Git push halts on "Writing Objects: 100%" to use git config –global sendpack.sideband false which worked perfectly.

I can finally push from the commandline again!

Fancie answered 10/1, 2018 at 11:25 Comment(0)
R
0

I spent hours trying to fix this and none of the recommendations worked. Out of frustration I moved the whole project to a backup folder, recloned a fresh and then copied over my files from backup folder. It worked!!. I suspect my issue was I committed node_module which was not excluded in .gitignore initially and removing from cache did not help/work. When I started from fresh the file size was a fraction compared to the earlier one.

Rostov answered 2/6, 2021 at 3:0 Comment(0)
B
0

This probably works for other Windows setups (I faced the issue on Windows 7 Pro 32 bits BTW and trying to push to Bitbucket, not Github).

I tried reinstalling Git and fiddling with the installer configuration.

Got it working with the OpenSSH setting left out and choosing Not to use one when choosing a credentials manager, which is probably what the SSH agent explained in other answers is called on GNU/Linux, so the hanging was probably due to waiting for an assumingly unavailable Windows credentials manager to respond.

Brakeman answered 15/6, 2021 at 19:56 Comment(0)
T
0

So when you type & enter git pish-u origin, GUI asking for your credentials should popup. In my case, after typing git pish-u origin, nothing happens until took a look at my task manager and found something running which I was certain was the GUI that should popup to ask your credentials. I decided to end its task. I was assuming that it will show an error on my gitbash but instead, the damn GUI finally showed up and I was able to finally progress.

Thaliathalidomide answered 17/6, 2021 at 17:14 Comment(0)
G
0

I was faced with the same problem.
I use Github desktop for the normal action and it can push or pull, but it doesn't support force push, when I try to do some rebase work and it always failed to push force.
I tried add core.askpass, config the proxy but all not work. Finally I decided to watch the log of Github desktop and I found it use below command to push:

git -c credential.helper= -c protocol.version=2 push origin

I tried this one with force flag and it work, it finally ask me for the user name and password.
I am not sure which configuration make it work, but I think this may help.

EDIT: I tried to install manager-core from here and I am able to push. It seems like manager-core is not installed properly.

Gigahertz answered 1/7, 2021 at 2:53 Comment(0)
S
0

If you use windows credential manager, use CMD instead of git Bash. Then you can add an authentication method to proceed. This worked for me.

Selfwill answered 15/9, 2021 at 17:14 Comment(0)
S
0

I experienced this in andorid studio.
Actually, on git push, the progress bar kept running and nothing happened;
I used to push code using token;

Here is what i did:

  1. in android studio opened terminal.
  2. entered
git push
  1. when email and password were asked on gui, i closed the dialogue box.
  2. after that i was prompted for user name on terminal, so i did it.
  3. after that i was asked password, where instead of password, i entered the access token.
git push
Logon failed, use ctrl+c to cancel basic credential prompt.
Username for 'https://github.com': abcxyz
Password for 'https://[email protected]': ____

and voila.

Shrewsbury answered 5/8, 2022 at 4:52 Comment(0)
P
0

If you are in VSCode it may also be the case that the GitHub VSCode extension wants to open GitHub to sign in.

If you click to fast you that popup and then all successive git push will get stuck even when you execute them from the VSCode terminal.

Solution: Close VSCode, open the project root again in a fresh window. When prompted follow the link and sign in. That's it.

Pilgrimage answered 22/8, 2022 at 16:48 Comment(0)
S
0

Turning off Virgin Media WebSafe fixed this issue for me. Assume other ISPs have similar toggle-able safety features.

Slacker answered 24/8, 2022 at 15:51 Comment(0)
L
0

For me none of above worked. I tried this one and it worked:

git push --set-upstream origin main

Loosen answered 28/9, 2022 at 4:23 Comment(0)
F
0

Faced the same problem tried several solutions then -

Tried "git push" command on VS code's integrated terminal within a second git credential authorization pop-up appeared with "open with browser" option then provided the github's username and password on chrome and the code pushed successfully

Frankpledge answered 26/9, 2023 at 16:35 Comment(0)
D
0

None of the answers worked for me, so, in my case, I just had to change the port for my ssh connections in the ~/.ssh/config file, like this:

Host github.com
  Hostname ssh.github.com
  Port 443
  User git
  IdentityFile ~/.ssh/id_rsa
  IdentitiesOnly yes
Diplocardiac answered 3/1, 2024 at 21:13 Comment(2)
None of them? Did you try all 38?Gambrill
I was being hyperbolic, but it took at least the first 10 solutions until I tried this oneDiplocardiac
E
0

If you are using a repository from Google Cloud. Updating gcloud to the latest version fixed the issue for me. The git push command was stuck after cloning the repository and pushing the first commit.

Eviscerate answered 14/1, 2024 at 14:10 Comment(0)
R
0

In my case it was an incorrectly configured IPv6 network interface. I turned off IPv6 in my system settings and it worked with IPv4.

Rozanne answered 17/3, 2024 at 21:42 Comment(0)
L
-1

I had two repositories, pushing to one of which worked fine. So, I compared their .git/config. The non-working one had at the end:

[http]
    sslVerify = false

The working one had instead:

[credential]
    helper = store

Changing .git/config solved the problem.

Lavone answered 12/11, 2018 at 15:1 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.