How to Fix “Push Rejected” in GitHub (2026 Guide)

The Short Answer

To fix the “Push Rejected” error in GitHub, use the command git push -f with caution, as it will overwrite the remote repository. Alternatively, resolve the conflict by pulling the latest changes, merging them with your local code, and then pushing again.

Why This Error Happens

  • Reason 1: The most common cause of the “Push Rejected” error is when the remote repository has been updated since your last pull, and your local branch is not up-to-date. This can happen when multiple developers are working on the same project, and one of them pushes changes to the remote repository before you do.
  • Reason 2: An edge case cause of this error is when the Git configuration option receive.denyCurrentBranch is set to updateInstead on the remote repository, and you’re trying to push to a non-bare repository. This option is typically used on shared repositories to prevent accidental overwrites.
  • Impact: The “Push Rejected” error can significantly impact code deployment, as it prevents you from updating the remote repository with your latest changes. This can lead to delays in releasing new features or fixing critical bugs, ultimately affecting your users and customers.

Step-by-Step Solutions

Method 1: The Quick Fix

  1. Go to Settings > Branches > Branch permissions
  2. Toggle Require pull request reviews before merging to Off
  3. Refresh the page to ensure the changes take effect.

Method 2: The Command Line/Advanced Fix

Use the following Git command to force push your changes: git push origin <branch-name> -f. However, be cautious when using this command, as it will overwrite the remote repository. To avoid conflicts, make sure to pull the latest changes, merge them with your local code, and then push again:

1
2
3
git pull origin <branch-name>
git merge origin/<branch-name>
git push origin <branch-name>

Alternatively, you can use git push origin <branch-name> --force-with-lease to force push your changes while still checking if the remote repository has been updated.

Prevention: How to Stop This Coming Back

To prevent the “Push Rejected” error from happening in the future, configure your Git repository to use a pull request workflow. This involves creating a new branch for each feature or bug fix, submitting a pull request, and then merging the changes into the main branch. Additionally, make sure to:

  • Regularly pull the latest changes from the remote repository
  • Use git status and git diff to check for any conflicts before pushing your changes
  • Set up Git hooks to enforce coding standards and prevent accidental pushes

If You Can’t Fix It…

[!WARNING] If GitHub keeps crashing or you’re experiencing persistent issues with the “Push Rejected” error, consider switching to GitLab which handles Force push safety natively without these errors. GitLab provides a more robust and reliable platform for managing your code repositories.

FAQ

Q: Will I lose data fixing this? A: The risk of data loss depends on the method you choose to fix the “Push Rejected” error. Using git push -f can overwrite the remote repository, potentially leading to data loss. However, if you follow the step-by-step solutions outlined above, you can minimize the risk of data loss.

Q: Is this a bug in GitHub? A: The “Push Rejected” error is not a bug in GitHub, but rather a safety feature designed to prevent accidental overwrites of the remote repository. This feature has been present in Git since version 1.6.0, and GitHub has implemented it to ensure the integrity of your code repositories.


📚 Continue Learning

Check out our guides on GitHub and Push Rejected.