[github] GitHub - error: failed to push some refs to '[email protected]:myrepo.git'

I am getting the following error. How do I resolve?: git add . git commit -m 't' git push origin development

To [email protected]:myrepo.git
 ! [rejected]        development -> development (non-fast-forward)
error: failed to push some refs to '[email protected]:myrepo.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.

This question is related to github

The answer is


I have faced the same issue and resolved as follows (if you have a project in local folder then follow the steps):

  1. create a new repo in guthub
  2. go to local folder and do "git init"
  3. git remote add origin (with your repo url) // simply copy from your repo
  4. git add -A
  5. git commit -m "your commit"
  6. git push -u origin master

Try this:

  1. git push -u origin master
  2. git push -f origin master

Sometimes #1 works and sometimes #2 for me. I am not sure why it reacts in this way


In my case. I had the error because I forgot to make a commit after create a repository on github into an existing project. So I solved:

git add .
git commit -m"commentary"

Then I was able to type:

git push -u origin master

In my case git push was trying to push more that just the current branch, therefore, I got this error since the other branches were not in sync.

To fix that you could use: git config --global push.default simple That will make git to only push the current branch.

This will only work on more recent versions of git. i.e.: won't work on 1.7.9.5


In my case Github was down.

Maybe also check https://www.githubstatus.com/

You can subscribe to notifications per email and text to know when you can push your changes again.


In windows, you need to use double quotes "". So the command would be

git commit -m "t"


$ git fetch --unshallow origin
$ git push you remote name

you can write in your console:

git pull origin

then press TAB and write your "master" repository


I used this command and it worked fine with me:

>git push -f origin master

But notice, that may delete some files you already have on the remote repo. That came in handy with me as the scenario was different; I was pushing my local project to the remote repo which was empty but the READ.ME