Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git push is stuck when pushing to remote

Tags:

git

When I try to push to a remote repository,

git push origin xyz

it gets stuck. I try ssh -T [email protected] and I get a success:

You've successfully authenticated, but GitHub does not provide shell access.

When I use the verbose option, I get a message that it is pushing:

git push -v origin xyz

Pushing to [email protected]:repo.git

and it times out after about 10 minutes with another message:

Connection to github.com closed by remote host.

And I do not get the prompt back in the shell.

I have tried the following but to no avail:

  • including the --dry-run switch with push results the same.
  • git clean -d -f -i followd by git gc --auto

I am on macOS High Sierra and using SSH authentication.

like image 495
swifthorseman Avatar asked Feb 12 '18 11:02

swifthorseman


People also ask

Why git push is not working?

If git push origin master not working , all you need to do is edit that file with your favourite editor and change the URL = setting to your new location. Assuming the new repository is correctly set up and you have your URL right, you'll easily be able to push and pull to and from your new remote location.

Why is git push taking so long?

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 .

How do I force a git push?

To force a push to only one branch, use a + in front of the refspec to push (e.g git push origin +master to force a push to the master branch).


1 Answers

It turned out it was stuck due to a pre-push commit hook which was placed there (at <repository-root>/.git/hooks/pre-push) by a third-party tool.

To debug, I ran the command with GIT_TRACE on:

$ GIT_TRACE=1 git push -v origin xyz
11:47:11.950226 git.c:340               trace: built-in: git 'push' '-v' 'origin' ‘xyz’
Pushing to [email protected]:repo.git
11:47:11.951795 run-command.c:626       trace: run_command: 'ssh' '[email protected]' 'git-receive-pack ‘\’’repo.git'\'''
11:47:13.100323 run-command.c:626       trace: run_command: '.git/hooks/pre-push' 'origin' '[email protected]'

Deleting the pre-push file solved the problem.

like image 179
swifthorseman Avatar answered Sep 24 '22 17:09

swifthorseman