Git remote push fails with SSH connection error

I’m having trouble pushing my local changes to a remote repository. I set up SSH authentication and can connect successfully, but when I try to push my code I get an error.

When I run:

$ git push upstream main

I see this error message:

ssh: github: no address associated with name
fatal: The remote end hung up unexpectedly

I tried fixing the remote URL with:

$ git remote set-url upstream git@github:username/myproject.git

But that didn’t solve the problem. I’m working on Windows 7 64-bit using Git Bash terminal.

UPDATE: Now I’m dealing with a merge conflict issue. After pulling changes, I removed files with rm --cached and tried adding new files, but Git says “you cannot do a partial commit during a merge.” When I try to merge, it tells me “you have not concluded your merge (MERGE_HEAD exists).” I can’t commit because of the merge and can’t merge because of the commit. How do I break this cycle?

I’ve hit this exact issue on Windows before. Yeah, you’re missing the .com in your SSH URL, but there’s another Windows gotcha that might be screwing you over. Check if you’ve got multiple SSH clients installed - PuTTY’s plink loves to mess with Git’s SSH. Run git config --global core.sshCommand "ssh" to force Git to use its built-in SSH client. For the merge mess, run git status first to see what’s staged, then git merge --abort to bail out. Once you’re back to a clean state, fix your remote URL to [email protected]:username/myproject.git and test with ssh -T [email protected] before trying to push again.

It appears that your SSH URL is incorrect. You should use [email protected]:username/myproject.git instead of git@github:username/myproject.git to establish a proper connection.

Regarding the merge conflicts, you’re currently in an unfinished merge state. You can run git status to identify which files are causing the issues. To resolve this, you can either resolve the conflicts and commit with git commit, or you can abort the merge using git merge --abort, which will revert everything back to its previous state. This allows you to fix the remote URL issue first, as Git won’t allow any commits until the merge conflicts are resolved.

That DNS error means your SSH config is probably pointing to a bad hostname. Check your .ssh/config file - there might be a custom ‘github’ entry that’s messing things up. Either delete it or make sure it points to github.com. For the merge conflict - you’re stuck because Git wants you to finish the merge. Since you used rm --cached, your staging area is probably messed up too. Run git reset --hard HEAD to bail out of the merge completely and get back to a clean state. Just heads up - this kills any uncommitted changes, so back up anything you need first. After that, fix your remote URL and try pushing again.

you got a typo in your SSH URL - should be [email protected]:username/myproject.git, not git@github:. for the merge issue, try git merge --abort to fix it, then fix your remote and push again. quickest way to solve this.