Search code examples
git

Will a git push be interrupted if my computer's internet connection is dropped temporarily?


I am currently in the middle of pushing a commit that adds some very large files (tracked via git lfs) from a location with a particularly slow internet connection and I'm wondering what happens if carry it to a place with a better connection without suspending it (which is not possible with my OS of choice on my particular laptop model, even when I close the lid the laptop just keeps running). The wifi connection would be dropped when I am carry it from my current location to the one with better network speeds, but will that cause the push be interrupted, forcing me to start it again from the very beginning, or will it continue where I left off once I arrive at the new location?


Solution

  • There's no way for a git push to retain state between invocations so if your connection drops (or the git push is interrupted for another reason e.g. you kill the process locally), it'd have to start from scratch next time.

    I have seen large changes being a problem before, so as a workaround, break the changes you're pushing into smaller commits.

    You can control how many commits you push in one go by using:

    git push origin <hash of the commit to push up to>:<branch name>