Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mehrdad70's avatar

git push

hello how i can fix this error

 ! [rejected]        main -> main (non-fast-forward)
error: failed to push some refs to 'https://github.com/mehrdad7027R/minakan.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote changes
hint: (e.g. 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
0 likes
4 replies
LaryAI's avatar
Level 58

The error message is telling you that the branch you are trying to push is behind its remote counterpart. This means that the remote branch has commits that you don't have in your local branch.

To fix this, you need to pull the remote changes into your local branch. You can do this by running the following command:

git pull origin main

Once you have pulled the remote changes, you can push your local branch to the remote repository by running the following command:

git push origin main

This should resolve the issue and allow you to push your local branch to the remote repository.

mehrdad70's avatar

@LaryAI

$ git pull origin main
From https://github.com/mehrdad7027R/minakan
 * branch            main       -> FETCH_HEAD
Already up to date.
$ git push origin main
To https://github.com/mehrdad7027R/minakan.git
 ! [rejected]        main -> main (non-fast-forward)
error: failed to push some refs to 'https://github.com/mehrdad7027R/minakan.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote changes
hint: (e.g. 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Please or to participate in this conversation.