machine parsable method of comparing the current branch to the local view of the tracking branch

StackOverflow https://stackoverflow.com/questions/16274874

  •  13-04-2022
  •  | 
  •  

Frage

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

War es hilfreich?

Lösung

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”.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top