문제

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 of origin/bar and use the local branch to diff against. Or you can just use git hash of topmost revision origin/bar.

Or you can put a symlink refs/remotes/origin/bar -> .git/refs/foo and then do diffs against foo. That would actually point to up-to-date origin/bar without being called origin/...

I'm not quite sure, though, why would you want to do that.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top