0

sometimes I have some problems when I try to push my code to github. Let me explain the scenario:

I work with only master branch (because my product is at early stages and there is no need for creating a feature branch for now). My remote repository is at github and I am the only person that I am working on the project, so there is no parallel modifications of master branch.

Then I write some code, and after all tests of what I am coding are green, I commit to my local repository and to github using egit. No problem all changes are pushed to github, but sometimes, don't know exactly why because I "theory" (or at least for me is what it seems) egit (in fact git) does not allow me to push the changes claiming that master:master [rejected] error. In push to window I put as source ref and dest ref the [master] branch and I add "all branches spec". Of course in this cases I have to pull from remote and merge code and then recommit again. I understand the theory of why this happens current branch is behind remote branch, but why this happens if I am the only who are modifying the code in a linear way?

It works in most cases but why sometimes this error happens? I could understand if we were a team of developers pushing to same github account, but this is not the case.

CharlesB
  • 86,532
  • 28
  • 194
  • 218
lordofthejars
  • 713
  • 1
  • 6
  • 14
  • possible duplicate of [eclipse and github: master: master rejected?](http://stackoverflow.com/questions/8145707/eclipse-and-github-master-master-rejected) – CharlesB Jun 20 '12 at 08:25
  • Thanks Charles yes I have already read this and with fetch and merge the problem normally disappear (not always sometimes I have reset local master branch with remote master branch), but my question is how I have arrived at this situation. See that in post is noted that _The reason your change is rejected is that the current master on Github does not appear anywhere in the history of your master branch._ But how this could happens if I am the only developer and I am always committing changes and then pushing to github? How github branch could be more advanced than local? – lordofthejars Jun 20 '12 at 08:37
  • you need more details about the error. you should run git push from the original git distribution, egit isn't giving enough information – CharlesB Jun 20 '12 at 08:38

1 Answers1

0

This can happen, if you do rebases or resets on your master branch. These operations change the history of a branch, so that the tip of the github master branch is no longer in the line of your local master branch. Thus you get the "rejected" error messages.

dunni
  • 43,386
  • 10
  • 104
  • 99