Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: Stop git push

Tags:

git

I'm pushing a large file to git, but have a very slow connection. What is the safest way to terminate this push (mid-push), and resume it when I have a better connection?

like image 762
Adam_G Avatar asked Jul 30 '12 20:07

Adam_G


People also ask

How do I stop git push?

The trick to prevent accidentally pushing in-development changes to the wrong environment is to use the git command for changing remote's URL. By adding the --push flag to the command, only the push URL is manipulated. So it is still possible to pull from that remote.

What happens if you cancel a git push?

The upstream Git repository will be oblivious to your attempted push, and no change will occur upstream.

Can you undo a git push?

We show three methods to undo pushed commits from a remote repository in Git. We use the git reset , revert , and checkout commands for this. When we use git reset , we also remove any trace of the unwanted commits from the repository history.

What is the git push command?

The git push command is used to upload local repository content to a remote repository. Pushing is how you transfer commits from your local repository to a remote repo. It's the counterpart to git fetch , but whereas fetching imports commits to local branches, pushing exports commits to remote branches.


2 Answers

Killing the client (Ctrl+C or any other method) won't cause the data on the server to be corrupted, if that's what you mean by "safe". The server doesn't update anything until all the blobs are transferred successfully, then it updates the refs to point to the new blobs.

Git doesn't have any facilities to resume an interrupted transfer though, so you'll probably have to transfer the big blob again when you have a faster connection.

like image 113
Greg Hewgill Avatar answered Sep 19 '22 20:09

Greg Hewgill


I believe git push is atomic, meaning that if you just Ctrl-C out of the operation, the remote repository will be in its original state, prior to the push. This also means that, when you do the push again, it will be starting over from the beginning. But it doesn't sound like that's necessarily a problem for you.

like image 24
KevinH Avatar answered Sep 21 '22 20:09

KevinH