Git only accepts a push that adds commits on top of whatever the remote already has, a so-called fast-forward. If someone else (or you, from another machine) pushed a commit you don’t have, accepting your push would erase it, so Git refuses and prints:
! [rejected] main -> main (fetch first)
error: failed to push some refs to 'github.com:user/repo.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally.
Read the reason in parentheses
| Message | Meaning | Fix |
|---|---|---|
(fetch first) or (non-fast-forward) |
The remote has commits you don’t | git pull --rebase, then git push |
(protected branch hook declined) |
The branch is protected against direct pushes | Push a new branch and open a pull request |
GH013: Repository rule violations found or GH009: Secrets detected! |
GitHub found a secret or a rule violation | Remove the secret from the commit |
this exceeds GitHub's file size limit of 100.00 MB |
A file is over the limit | Remove it from history and add it to .gitignore |
(Working directory has unstaged changes) |
You’re pushing to a server-side repository with modified files | Commit or discard the server’s changes |
How to fix it
1. The usual case: fetch first
git fetch origin
git status
git pull --rebase origin main
git push origin main
If you hit a conflict:
git status # lists conflicted files
# edit them and remove the <<<<<<< and >>>>>>> markers
git add path/to/file
git rebase --continue
git push origin main
To back out entirely: git rebase --abort.
2. Protected branch
git switch -c fix/login-page
git push -u origin fix/login-page
Then open a pull request from the repository page on GitHub.
3. A secret in the commit
git reset --soft HEAD~1 # undo the last commit, keep the changes
echo ".env" >> .gitignore
git rm --cached .env
git commit -m "Move secrets to environment variables"
git push origin main
Move the key into environment variables and rotate it in the service that issued it: anything that entered Git history should be treated as exposed.
4. An oversized file
If it’s only in the last commit:
git rm --cached backup.zip
echo "backup.zip" >> .gitignore
git commit --amend --no-edit
git push origin main
If it’s in older commits, you’ll need a tool such as git filter-repo to strip it from the whole history.
5. A server repository with local edits
If you edited files directly on the server (in File Manager, say) and then push to that same repository, Git refuses so it won’t overwrite those edits. Over SSH:
cd ~/repositories/mysite
git status
git stash # set the changes aside, or: git checkout -- . to discard them
Prevention
- Start each work session with
git pull --rebase, or make it the default:git config --global pull.rebase true. - Don’t edit files by hand on a server that’s deployed through Git.
- Work on branches and merge through pull requests.
- Put
.env,node_modulesandvendorin.gitignorefrom the first commit.
On ArabyHost
Git is available on the AI/Developer plans, along with SSH and Composer. You deploy from GitHub through cPanel’s Git Version Control with a .cpanel.yml file: after pushing to GitHub, open the repository → Manage → Pull or Deploy, then Update from Remote and Deploy HEAD Commit (see the cPanel Git deploy guide and deploy from GitHub). You can also deploy from the Git tab in the Araby Panel as described in this help page, upload a ZIP, or deploy from Claude or Cursor through Araby MCP. If the push fails on authentication instead, see Permission denied (publickey).
FAQ
Should I use git push --force?
Not on a branch other people use: it deletes their commits from the remote. If the branch is truly yours alone, use git push --force-with-lease, which refuses to overwrite commits you haven't seen.
What's the difference between git pull and git pull --rebase?
A plain pull merges the two lines of work with a new merge commit; --rebase replays your commits on top of the latest remote state, keeping history linear and easier to read. Either one resolves the rejection.
Why is my push rejected with Permission denied?
That isn't a rejection of your commits but an authentication failure: the key or token isn't valid. See the Permission denied (publickey) page to fix your key.