So, you’ve run into the following VERY annoying message:
master:master [rejected – non-fast-forward]
If you are a nube to Git, which I certainly am, you have no clue what this means, why it’s happening, or how to fix it. Also, if you’ve traveled down the same path I have, then you’ve encountered this message after one of the following scenarios:
- Used EGit in Eclipse to connect a local repository to an already created repository on GitHub. After setting correct SSH and then trying to push, you get said message.
- Local repository has been pushing to remote repository on GitHub forever and randomly crapped out with the message.
If so, then the problem is most likely that your local and remote repositories are out of sync, and there’s a conflict between some files. Follow the procedure below to resolve this problem.
- First, make sure the most recent changes have been committed. To do this, in Eclipse, right-click on the application’s folder->Team->Commit. If a pop-up does not say “Up-to-date”, then finish committing the current changes to the local repository. If it’s already up-to-date, continue.
- Try to pull from the remote repository to the local repository; then push to it. To do this, in Eclipse, right-click on the application’s folder->Team->Fetch From Upstream. If you were able to pull, then push by right-click on the application’s folder->Team->Fetch From Upstream. If unable to pull because of an error, then continue.
- At this point, I had to force a push from my local repository to remote repository on Github. Forcing a push will override any changes on Github with the changes from your local repository! If this is not your goal, DON’T CONTINUE. If it is your goal then do the following:
- Right-click on application’s Folder->Team->Remote->Configure Push To Upstream
- Configuration dialog will pop-up->Under “Ref mapping” hit “Advanced” button
- Push Ref Specifications will pop-up->Select “master [branch]” under “Source Ref” and “Destination Ref”
- In same window select “add spec”
- You should now see this update in the “Specifications for push” window; select “Force Push” next to it
- Select “Finish”
At this point my problem was fixed, but I also didn’t care about throwing away changes on GitHub. If you are concerned about this, please keep Googleing because I don’t know how to fix it.