71

When I am trying to push to my remote git repository, but it is taking forever and nothing happens. I waited for so long, but push is never getting finished. My OS is Ubuntu 12.10. Thank you.

mvp
  • 111,019
  • 13
  • 122
  • 148
Codeformer
  • 2,060
  • 9
  • 28
  • 46
  • 6
    Can you browse github manually? are you behind a proxy? What happens when you add `--verbose`? We need more info to help you – phisch Mar 02 '13 at 14:46
  • Yes, I am able to do everything else , Pull , fetch , commit locally and browse through github. The only problem is while pushing. It never happens I waited for so long ,so many times. Some times I got No fast-forward error, But then i pulled from repository to resolve it and when I pushed, then it just goes on but never ends. – Codeformer Mar 02 '13 at 15:06
  • Please provide more info. Are you using `ssh` or `https` remote url? How big is your repository? Is it possible that repository is hundreds of megabytes because of some commit you did recently with a huge binary files? – mvp Mar 02 '13 at 23:17
  • 1
    How long is “forever”? – Waleed Khan Mar 02 '13 at 23:21
  • 12
    @WaleedKhan ∞ seconds. :-) – James M Mar 02 '13 at 23:27
  • @mvp Repository is of 200mb, But the recent commits were small. I am using https. – Codeformer Mar 03 '13 at 02:02
  • It stops at `Pushing to git@heroku.com:appname.git`. I am using Ubuntu 14.04. – Kevin May 20 '14 at 10:59
  • Sometimes I forget that the pop-ups can hide behind the command prompt. – MJ DLS Feb 24 '22 at 11:52

13 Answers13

73

Try using the --verbose option to see what actually happens. Even if you did small changes, some internal things might cause git to push a lot more data.

Have a look at git gc. It cleans up your local repository and might speed up things, depending on you issue. Backup strongly advised.

phisch
  • 4,571
  • 2
  • 34
  • 52
17

I had the same problem. If you are using Bitbucket.org, I don't know why, but disabling IPV6 connection fixed the problem.

Felipe Desiderati
  • 2,414
  • 3
  • 24
  • 42
  • 1
    How did you disabled IPV6? – Fernando Santiago Jun 05 '20 at 21:56
  • It will depend on the SO which you use. In Ubuntu, using the UI, it would be: Settings > Network > Ipv6 Tab > Disable. But there are other methods. – Felipe Desiderati Jun 05 '20 at 22:35
  • Thank you! This is probably related to some router configurations blocking specific ipv6 traffic or even the local internet provider blocking it. *If you don't need to use any ipv6 services*, disabling it will make it work fine (on Ubuntu, make sure to disable it via `/etc/sysctl.conf`). *If you need ipv6*, then force your PC to use bitbucket's ipv4 by adding this to your hosts file: `104.192.143.3 bitbucket.org` – vinitius Apr 21 '21 at 05:13
  • 3
    I had almost the same issue. In my case it was a git repository hosted via Plesk's Git feature. Instead of disabling IPv6 completely you could also just force git to use IPv4 (at least in 2022 :). As example while push: `git push --ipv4 your-remote` `git push --ipv6 your-remote` Editing the question was unfortunately blocked by "There are too many pending edits on Stack Overflow. Please try again later." ... – Eddie Nov 26 '22 at 16:53
  • The same worked for GitHub. – Chaitanya Bankanhal Dec 28 '22 at 09:17
8

Ensure you're using the right protocol.

Depending on how you have your local configurations set up, you might need to use https to connect. To do so, switch the protocol for the remote repository from the git@github.com:[user]/[repo] protocol to the https://github.com/[user]/[repo].git protocol.

Also, it's worth trying vice versa, if you're unable to use the https protocol. On older configurations, the older git@github user authentication will often allow you to connect as a fallback.

Tony Brasunas
  • 4,012
  • 3
  • 39
  • 51
  • This worked for me again today. But it was switching to the git@github protocol that worked. For me, it might have to do with some config options on GitExtensions, which is the git client I'm using. – Tony Brasunas Jul 28 '14 at 18:59
  • 1
    I changed my remote to use ssh from https, and this issue started, I went back to https and worked for me now. – Ranvir Apr 27 '21 at 01:19
7

I have faced a similar issue using git bash. Using these commands helped.

git config --global core.preloadindex true  
git config --global core.fscache true 
git config --global gc.auto 256

https://blog.praveen.science/solution-to-git-bash-is-very-slow-in-windows/

abhinay_cf
  • 71
  • 1
  • 2
4

Ensure you are authenticated to github: For me, it was my authentication. I was running the command with git bash on windows and for some reason, it didn't prompt me to authenticate. when I ran it with the command prompt, I got this

Select an authentication method for 'https://github.com/':
1. Web browser (default)
2. Personal access token
option (enter for default):

after I successfully authenticated, it worked fine

Azeez Lukman
  • 81
  • 1
  • 8
2

Please check the permission rights on the remote dir. In my case, after setting the correct permissions by chown -R user.group /dir, the commit is correctly finished:

$ git push --verbose
Pushing to ssh://user@domain.zone:port/dir
user@domain.zone's password:
Counting objects: ...
...
Total 123 (delta 21), reused 16 (delta 12)
To ssh://domain.zone:port/dir
 * [new branch]      master -> master
updating local tracking ref 'refs/remotes/origin/master'
Alexander Lubyagin
  • 1,346
  • 1
  • 16
  • 30
1

One possibility might be that you have large binary file(s) commited in the latest commit. git is not good at working with binary file. If commiting binary files was a mistake, you can refer to following answer for getting rid of binary file in commit.

https://stackoverflow.com/a/58987943/8694152

MS_
  • 741
  • 1
  • 6
  • 10
1

Every time I reinstall or upgrade Ubuntu (all 3-4 times), I had to go to the DNS settings of my internet connection (both Ethernet and Wifi), remove Automatic and add 8.8.8.8 and 1.1.1.1. After a reset git push and all other git-origin-accessing commands go down from 1 minute to a few seconds.

Bill Kotsias
  • 3,258
  • 6
  • 33
  • 60
1

For people cloning repositories and then pushing to a new remote -

If you are starting a new project from a clone, (from the CLI without a fork) when you push to a blank remote you are pushing the entire history of the project you just cloned. This is going to take some time. If you just need the clone as it stands and you don't want the history, delete the .git directory after you clone it, then re-initialize the local repo with git init and push it to your new remote. Should push quickly.

0

It might be some kind of

Delete every settings file related to the keywords "vcs" and "git" in the app data directories of your IDE (Search "vcs" and "git" in the search bar and delete every file you see in the results):

For example if you use Android Studio:

  1. C:/Users/%USER%/AppData/Local/Google/AndroidStudio%VERSION%

  2. C:/Users/%USER%/AppData/Roaming/Google/AndroidStudio%VERSION%

And then restart your IDE!

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 17 '21 at 21:48
0

For me it was vpn. When i disconnected from vpn it resolved.

0

I resolved my problem by rebasing my branch with the develop branch (working in a team). Here is how rebasing works.

Big Zed
  • 417
  • 5
  • 11
0

I also experienced a similar blocking at git push in my linux shell. For me, the problem seemed to be related to X11 forwarding, as git wanted to ask my password in a dedicated x window (Qt?)... After making sure I could open a "xeyes" window, git push worked directly. Hoping this could give you a hint if above solutions don't work :) Cheers

fangorn
  • 31
  • 2