0

I need a machine parsable way of comparing the current branch to the local copy of the tracking branch.

These are the ideas I've tried, with their caveats:

  • git status: not guaranteed to stay the same between different versions of git
  • git status --porcelain: doesn't output the required information
  • compare head of branch to head of origin/branch: Can we guarantee that the tracking branch is on "origin"?

Thanks for any ideas

Sparky
  • 2,694
  • 3
  • 21
  • 31
  • You can use `git diff --name-status` or `git diff --name-only` to get some fairly machine parseable output. I don't really understand your 3rd question though, about having a guarantee that the tracking branch is on origin. Can you explain that more? –  Apr 29 '13 at 14:06

1 Answers1

2

I think the command you are looking for is:

git rev-list HEAD..HEAD@{u}

This will list all commit SHAs that are on the tracking branch but not your local branch. rev-list is simply command for listing revisions and the @{u} on a branch name means “the remote tracking-branch of this branch”.

Chronial
  • 66,706
  • 14
  • 93
  • 99