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?
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.
The upstream Git repository will be oblivious to your attempted push, and no change will occur upstream.
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.
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.
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.
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.
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