Untitled.Bat |
Developer, dad & dangerously dopey.....Also awesome at alliteration and assonance . Visit my main website @ http://www.xerxesb.com if you're tech-inclined |
Why is my push rejected with a non-fast forward error? If you try to push a branch, you might get this error message: ! [rejected] master -> master (non-fast forward)
error: failed to push some refs to ‘git@github.com:pieter/gitx.git’
This means that your branch is not a strict superset of the remote side. That is, the remote side has commits that your side does not have. If you would push, the other side would lose changes. The most likely reason for this is that you need to pull from the remote first. You can see what changes the remote side has by fetching first and then checking the log. For example, git fetch origin git log master..origin/master
will list all the changes the remote side has that your side doesn’t. If you want a graphical representation, use gitk —left-right master…origin/master. The arrows to the left are changes you want to push, the arrows to the right are changes on the remote side. If you have rebased your branch and try to push that, see the next question. If you think you know what you are doing, you can also try: git push origin +branchname
This will force the update. If you don’t have permission, then sometimes this will work: git push origin :branchname git push origin +branchname
ie, delete the branch remotely first (this is often permitted), then re-push the “new” (or perhaps rewound) branch. Be warned that if you rewind branches, others might get into problem when pulling. There is the chance that they will merge in the branch that they fetched with the new one that you’ve published, effectively keeping the changes that you are trying to get rid of. However, it will only be their copies that have the bad revisions. For this reason, rewinding branches is considered mildly antisocial. Nonetheless, it is often appropriate.