I decided to try to mess around with Git today and try to learn how its branching system works. Bad idea. I somehow have gotten myself in a state where I have committed a change on a branch, and when I do "git push" I get:
To [email protected]:LAW/Repo.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to '[email protected]:LAW/Repo.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.
I've seen this a few times, and I have done "git pull" to resolve, though I'm not sure why or how that resolves things. The problem is, it isn't working now. I do "git pull" and get:
"Already up-to-date."
And the problem persists. So my question is...now what? I can't push from the branch, so it is essentially dead, but the internet has no better advice than "git pull" to fix this. Needless to say this is VERY frustrating!
EDIT A commenter requested the output of "git branch -a". The branch in question is "PersonalSite"
* PersonalSite
master
remotes/origin/HEAD -> origin/master
remotes/origin/PersonalSite
remotes/origin/master
Your rejected push is master -> master. But the branch you're on is PersonalSite. It sounds like your master branch has a local commit that remote doesn't, but is missing commits from remote. However, you're trying to git pull on PersonalSite. I'm not sure what branch it's trying to pull from, probably origin/master (this depends on the upstream information you may have set up when creating the branch). git push isn't trying to push PersonalSite since, by default, it only pushes "matching" branches (e.g. branches that already exist on both sides) and PersonalSite only exists locally.
What are you trying to achieve here? If you want to push PersonalSite to remote, use git push origin PersonalSite. If you want to fix your master branch, check it out and then run your git pull (or whatever else you want to do to fix it up).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With