Search code examples
gitbitbucketgit-push

Why am I obtaining this error pushing my code on GIT? Maybe is it a good idea create a branch?


I am trying to push a new version of my project on my repository using GIT (from the console) but I am obtaining this error message:

$ git push origin master
To https://bitbucket.org/MyUserName/glis-toolkit.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://MyUserName@bitbucket.org/MyUserName/glis-toolkit.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first 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 it means? What means that "failed to push some refs"? What are these "refs"?

Another consideration to do is that the version on my BitBucket repository is a working version of my system (that now is pretty different from the local one). I want to mantain it. Maybe is it better to create something like a branch for this new version?

If it could be a solution, how can I create a branch and push this new version on this branch?


Solution

  • Please use

    git pull origin <your branch> 
    

    befor pushing code. This might be happen because someone else also pushed some code on the branch and hence git asking forr first pulling those changes and the put your changes.