0

I want to delete my repo but I want to make sure all my changesets have been pushed. git log origin..HEAD and git log origin/master..master both show nothing. However, when I try git push, I get:

To remote-repo
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to '/van/work/nms/esteras/cmpt-bitArray-clean1.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.

If I have no local changes shouldn't it just say Everything up-to-date? If I have outgoing changes how can I tell what they are? I may not care about them but I need to know what they are to decide.

Stephen Rasku
  • 2,554
  • 7
  • 29
  • 51

2 Answers2

1

This could happen when the remote site has changes, or (worse) has been rebased (what is known as an operation rewriting history).

You can find the difference between your local HEAD (master) and the remote using this method:

Community
  • 1
  • 1
sehe
  • 374,641
  • 47
  • 450
  • 633
  • `git diff origin/master...master` is returning no output but I still get the error. – Stephen Rasku Nov 14 '12 at 23:28
  • @StephenRasku I think you missed [my answer](http://stackoverflow.com/a/5734957/85371) there. It is entirely possible to have _identical content_ with a _different_ history (e.g. after rebase, squash, merge etc.). This can lead to an 'incompatible' branch, where you'd have to merge or force the push. Look at `git log (options) origin/master...master` instead for differences in the revision ancestry! – sehe Nov 15 '12 at 00:40
  • `git log --left-right --graph --cherry-pick --oneline origin...origin/master` and `git log --left-right --graph --cherry-pick --oneline origin/master...origin` both return no output. – Stephen Rasku Nov 15 '12 at 16:30
  • First, `...` is _commutative_ (A...B is equivalent to B...A). Second: that is surprising. I can only _guess_ somehow you (a) are not locally up-to-date (`git remote update -prune`?) OR (b) are pushing to another branch/repository than you are comparing to. – sehe Nov 16 '12 at 08:04
  • ***Oh wait:*** (c) drop the `--cherry-pick` option in that log? It would show rebased commits as different, which is _exactly_ what you want to see here. This option is described in the man-page, or e.g. here: http://stackoverflow.com/a/7549118/85371 – sehe Nov 16 '12 at 08:05
  • I tried removing `--cherry-pick`. It made no difference. I did `update --prune`. I am still unable to push. I am pushing back to origin. I even explicitly did `git push origin` and it still gives the same problem. – Stephen Rasku Nov 16 '12 at 15:36
0

you want to be running git diff origin/master or git diff origin/master..master

git diff origin/master...master compares changes since your last push or rather changes that are in your local history that are not on the remote.

Michael
  • 10,124
  • 1
  • 34
  • 49
  • I want the list of changesets (i.e. `git log`) not the differences. `git diff` will show me what changed but not why. – Stephen Rasku Nov 15 '12 at 16:31
  • that is because you are seeing a common history with different data - this is entirely possible, so you want to check the diff for differences, log is not what changed or the differences, its a history and a comparison of logs is just that a comparison of history. If you want to see differences, use diff. – Michael Nov 15 '12 at 19:31
  • Like I said, I want the changesets not the diffs. Thanks anyway. – Stephen Rasku Nov 15 '12 at 21:00
  • There is no changeset - that is the point. You have a common history. That is a common problem with force pushes – Michael Nov 15 '12 at 22:28
  • I don't think I have a common history. I am assuming you are talking about the same changesets with different hashes. Is there a way to verify this? I don't see any evidence of this. – Stephen Rasku Nov 15 '12 at 23:44