Fix Git that will not push
We'll check the remote URL, branch tracking, authentication (SSH or HTTPS), and upstream conflicts—or tell you when to escalate.
What you'll need
- Git installed and a repository with commits to push
- Access to the remote (GitHub, GitLab, etc.)
At a glance
- Run `git push -v` to see the exact error (rejected, permission denied, auth failed).
- Check the remote URL with `git remote -v`—SSH vs HTTPS affects authentication.
- Confirm your branch is ahead with `git status` and `git log origin/main..HEAD`.
- If rejected: the remote has new commits—run `git pull --rebase` then `git push`.
- For SSH: check `~/.ssh/id_ed25519` or `~/.ssh/id_rsa` exists and `ssh -T [email protected]` works.
Quick triage — pick your path
Quick triage — pick your path
Choose the option that matches what you see. You can jump straight to that section.
Steps
Goal: Identify why push fails, then fix remote URL, branch tracking, auth, or upstream conflicts.
- Run
git push -vand note the error: rejected, permission denied, authentication failed, or connection refused. - Good: You see the exact failure. Proceed to Check the remote URL.
- Bad: No clear error—check network and that the remote host is reachable.
Check the remote URL
Goal: Confirm the remote uses SSH or HTTPS and matches your auth setup.
- Run
git remote -v. SSH URLs look like[email protected]:user/repo.git; HTTPS likehttps://github.com/user/repo.git. - If SSH: keys must be set up. If HTTPS: credentials or token must be valid.
- Good: The URL matches your auth method. Proceed to Fix rejected push or Fix auth based on the error.
- Bad: Wrong URL—run
git remote set-url origin <correct-url>.
Fix rejected push
Goal: Resolve “rejected (non-fast-forward)” when the remote has new commits.
- Run
git pull --rebaseto replay your commits on top of the remote. Resolve any conflicts if prompted. - Run
git pushagain. - Good: Push succeeds.
- Bad: Merge conflicts—see fix-git-says-merge-conflict.
Fix SSH or HTTPS auth
Goal: Fix permission denied or authentication failed.
- For SSH: run
ssh -T [email protected](or your host). Confirm~/.sshis 700 and the key file is 600. Add the public key to the host if missing. - For HTTPS: use a PAT instead of a password. Run
git pushand enter the token when prompted. - Good: Auth succeeds and push works.
- Bad: Key not added, wrong token, or proxy—see When to escalate.
When to escalate
Escalate if:
- The repo uses deploy keys or CI tokens you cannot change.
- The host is behind a corporate proxy.
- You get “repository not found” and you have confirmed access.
Provide git push -v output and git remote -v.
Verification
git pushcompletes without error.git statusshows “Your branch is up to date with origin/branch” or “nothing to commit, working tree clean.”git log origin/main..HEADis empty (all commits pushed).
Escalation ladder
Work from the device outward. Stop when the problem is fixed.
- Check push error Run git push -v to identify the failure.
- Remote and branch Check git remote -v and git status.
- Fix rejected git pull --rebase then git push.
- Fix auth SSH—test ssh -T; HTTPS—use PAT.
- Escalate Provide git push -v and git remote -v.
What to capture if you need help
Before calling support or posting for help, have these ready. It speeds everything up.
- git push -v output
- git remote -v output
- git status and git log origin/main..HEAD
- Steps already tried
Reviewed by Blackbox Atlas
Frequently asked questions
- Why would Git push fail?
- Common causes: remote has new commits (rejected), wrong or expired credentials, SSH key not loaded or not added to the host, or the branch does not exist on the remote. Run git push -v to see the error.
- What does "rejected (non-fast-forward)" mean?
- The remote branch has commits you do not have locally. Pull first with git pull --rebase, resolve any conflicts, then push again.
- How do I fix SSH authentication for Git?
- Confirm your key exists (~/.ssh/id_ed25519 or id_rsa), add it to the host (GitHub, GitLab, etc.), and test with ssh -T [email protected]. Check key permissions: ~/.ssh 700, key file 600.
Rate this guide
Was this helpful?
Thanks for your feedback.