Why I can't push this commit on my GIT repository? error: failed to push some refs to my_repo

Viewed 2486

I am finding the following problem pushing on my GIT (BitBucket) repository.

If I do git push I obtain the following error message:

$ git push
fatal: You are not currently on a branch.
To push the history leading to the current (detached HEAD)
state now, use

    git push origin HEAD:<name-of-remote-branch>

So I tried to do git push origin master but give me the following error message:

$ git push origin master
To https://bitbucket.org/AndreaNobiliProjects/glis-trigger.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://AndreaNobiliProjects@bitbucket.org/AndreaNobiliProjects/glis-trigger.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.

What could be the problem? How can I try to fix it?

I explain what I have done before obtain this error message:

  • I tried to push but I can't because on the repository there was some changes made by another person.
  • I pull from the repository but I don't want use these changes so I replaced the content of my project with my version (I had done a backup before the pull).
  • I commit and pushed again and I am obtaining this error.

What can I do to solve this situation?

3 Answers
Related