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:
--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.
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.
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 .
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).
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With