If you're having the all time classic Broken pipe: the remote hung up unexpectedly error, a quick way to solve it is switching your computer to another wifi network (like the one your smartphone can provide).
But if this keeps happening it's a pain to have to do it constantly. So another solution can be to set up a new remote (the thing that knows where the GitHub repo is), but this time through https instead of ssh. This way, if you get the broken pipe, you can patch it up in a single command.
- Go to the repo in GitHub
- Select
Clone or Download - Select
Use HTTPS - Copy the link
- In you terminal window, navigate to the repo's directory
- Type
git remote add origin-https {the address you copied from GitHub}and hit enter. This will try to add another remote, calledorigin-httpswhich points to the repo in GitHub but through HTTPS instead of SSH. - If you're be prompted for your GitHub username (not email!) and password and you have set up Multifactor Authentication in your account, your password won't work. You need to use a personal token, read for the steps to get it.
- Go back into GitHub > Settings > Developer Settings > Personal access tokens
- Generate a new token, give it
Reposcopes only and copy it - Retry the command at line 6 and when asked for your password, paste the personal token you just copied from GitHub.
- You're all set up.
When you're happy with what you've done and trying to push things to GitHub, but GitHub's being rude and hanging up on you unexpectedly, just try this:
git push origin-https {your-branch-name}
What this does is send your commits to the same GitHub repo, but through https, which won't hung up on you ever :P
