How can I compare a local branch against its remote upstream when I don't want to keep in mind what remote branch is its upstream?
In other words, I want to drop origin/bar
in the second line below:
git branch --set-upstream master origin/bar
git log origin/bar..
origin/bar
is just a convenient reference to the top revision of that branch in history that gets updated when you fetch changes from upstream.If you do care about complete content of that branch, something somewhere would have to have a reference to it (or else it would eventually be garbage collected) and you would have to figure out the hash of revision at the top of that branch.
If you don't care about updated changes, then you can use
git tag
to mark top of the upstream branch at some point and then use the tag to diff the changes. Or you can create local branch off the top oforigin/bar
and use the local branch to diff against. Or you can just use git hash of topmost revisionorigin/bar
.Or you can put a symlink
refs/remotes/origin/bar -> .git/refs/foo
and then do diffs againstfoo
. That would actually point to up-to-dateorigin/bar
without being calledorigin/...
I'm not quite sure, though, why would you want to do that.