Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens if you interrupt a Git push?

Tags:

git

I ran the following command:

git push -u origin master

The "push" was very big, many files, so it was taking time to upload. Halfway through I noticed I forgot to add a couple of files. So I did "Ctrl + C" in terminal (interrupting Git), and then after doing git add . , I committed again, and then pushed again.

Will Git know that the first one didn't go through ? It takes a really long time to push (so I can't test it easily. I have to wait for the push to finish which could take a while).

EDIT: Hooray! Nothing seems to have gone terribly wrong. All I did was push again, and everything works. :{

like image 574
Rahul Iyer Avatar asked Dec 05 '14 23:12

Rahul Iyer


People also ask

How do I stop git push?

If you wish to completely avoid push --force , both GitHub and GitLab offer a very cool feature called Protected Branches, which allows you to mark any branch as protected so no one can push --force to it.

Why would a push be rejected?

A commit gets rejected and causes a failed to push some refs to error because the remote branch contains code that you do not have locally. What this means is that your local git repository is not compatible with the remote origin. Based on the above, your local machine is missing commits C and D.

What happens if you commit without pushing?

So commiting changes without pushing allow the save-load behaviour done locally during development. Once you are happy with your work, you then commit AND push.

Can you remove a git push?

In order to delete a remote Git tag, use the “git push” command with the “–delete” option and specify the tag name. To delete a remote Git tag, you can also use the “git push” command and specify the tag name using the refs syntax.


1 Answers

The upstream Git repository will be oblivious to your attempted push, and no change will occur upstream. Unfortunately however, as it doesn't do anything with the half-pushed files, it doesn't store it and then expect a continuation of the push later on either. So it's either push or don't push, there is no try;)

like image 184
kinbiko Avatar answered Oct 16 '22 02:10

kinbiko