git push failure with no conflict

I've read a few explanations for a broken git push, but none of them seem to cover this case.

I'm unable to push my local changes to a remote repository, even after a pull and with no conflicts.

$ git pull
Already up-to-date

$ git st
# On branch unstable
nothing to commit (working directory clean)

$ git push
To ssh://<url>
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'ssh://<url>'
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.

<url> is, of course, the real URL of my repository.

There are no changes to pull, no conflicts, and I'm not sure what else could cause this to fail.

I believe I've got everything set up correctly:

$ git remote -v
origin  ssh://<url> (fetch)
origin  ssh://<url> (push)

$ git branch -v
  master   175a09d [behind 18] openReview must now be called from thread other than main.
* unstable c9e5cab Progress on attachments.

In the past, I've just deleted my local repository. However, this is happening more frequently.

  1. What caused this to happen?
  2. How can I avoid it in the future?
  3. How am I supposed to fix this?

Answers


Full disclosure - my git is a little rusty so this may not be 100% correct.

It appears that your local 'master' branch is behind the 'origin' master branch. When you run 'git push' it will attempt to update all the remote branches with your corresponding local branches. To just push your current branch, try git push origin unstable. Also, if you want your local master branch to get up-to-date, checkout the master branch and run git pull.


Need Your Help


About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.