What happens if you interrupt a Git push?

2020-08-14 07:11发布

问题:

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. :{

回答1:

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;)



标签: git