3

I screwed up pull with rebase (there were conflicts and I resolved them incorrectly). I think that the easiest way out now is to blow the tree and reapply my patches that are missing in the upstream (there are less than 10 of them).

So, how do I get the list of the commits that are present in the local tree but absent from the upstream master? (to be exported using format-patch).

$ git remote -v
origin  git@github.com:sam-s/vowpal_wabbit.git (fetch)
origin  git@github.com:sam-s/vowpal_wabbit.git (push)
upstream        git://github.com/JohnLangford/vowpal_wabbit.git (fetch)
upstream        git://github.com/JohnLangford/vowpal_wabbit.git (push)
sds
  • 58,617
  • 29
  • 161
  • 278
  • 1
    Before you assume you've messed it all up, have a look at previous references to see if you can go back to where you started (e.g. `master@{1}`). – cmbuckley Dec 23 '14 at 14:53
  • git diff master origin/master will give you the the changes that have yet to be pushed, but not a list of the commits – Joel Dec 23 '14 at 14:56
  • possible duplicate of [Using Git, show all commits that are in one branch, but not the other(s)](http://stackoverflow.com/questions/1710894/using-git-show-all-commits-that-are-in-one-branch-but-not-the-others). Let me know if your plan to use `format-patch` makes this not a duplicate. :) – Gordon Gustafson Dec 23 '14 at 14:57
  • @GordonGustafson: I am not using branches at all, I want to compare repositories, not branches. – sds Dec 23 '14 at 15:06
  • @sds Your repository may have only one branch, but you are in fact 'using branches'. To 'compare repositories', just compare their only branches, which are probably all called `master`. – Gordon Gustafson Dec 23 '14 at 15:45

2 Answers2

6

You can use the cherry tool;

git cherry -v origin/master

will list all patches which exist in the current HEAD, but not in master. It will prepend a + for patches which don't exist in origin/master, and a - for patches which exist in master but under a different commit (e.g. commit message changed or as a result of a rebase).

micromoses
  • 6,747
  • 2
  • 20
  • 29
  • this works with `1.9.3` but not `1.7.1`: `fatal: Unknown commit upstream/master`. what do I do? – sds Dec 23 '14 at 15:23
  • Are you sure you're working against a remote which is called `upstream`? Usually, the remote from which you cloned the repo is called `origin`. If you still have a problem, it would be helpful if you post the output of `git remote -v` – micromoses Dec 23 '14 at 16:06
  • I was partially able to reproduce the symptoms on 1.9.3, though I hardly think this is the same problem you're exhibiting. After running `git remote add upstream ...`, I ran `git fetch upstream` and the error was gone. Again, this seems like a stupid solution, but it's all I've got at the moment (will try to search in the source code/release notes later on). – micromoses Dec 23 '14 at 17:02
4

To show the commits in local-branch but NOT in origin/master:

git log local-branch ^origin/master

Replace origin with the name of the remote (upstream in your case).

Source (and duplicate?): Using Git, show all commits that are in one branch, but not the other(s)

Community
  • 1
  • 1
Gordon Gustafson
  • 40,133
  • 25
  • 115
  • 157
  • `fatal: ambiguous argument 'local-branch': unknown revision or path not in the working tree.` – sds Dec 23 '14 at 15:07
  • Replace `local-branch` with the name of the branch the commits are on. Run `git branch` to see your local branches. Based on your other comments, you probably only have one local branch called `master`. – Gordon Gustafson Dec 23 '14 at 15:41