How can one reference a git alias to perform an operation on the equivalent tracking branch on a remote repository called "origin"? For example, if I am on branch "foo" of my local repo, and I want to run a command that normally defaults to my "origin/foo" branch, how can I do so?
Here is a concrete example:
I want to see the incoming commits from my "origin/foo" branch, and I am on my local "foo" branch. To do so, I would run git fetch && git log --pretty=oneline --abbrev-commit ..origin/foo
. Thus, I set up a git incoming
alias as follows:
[alias]
incoming = !git fetch && git log --pretty=oneline --abbrev-commit ..@{u}
However, this alias is interpreted as git fetch && git log --pretty=oneline --abbrev-commit ..upstream/foo
, where the @{u}
is a substitute for the equivalent branch on the upstream remote. I want to do the same command, but on the equivalent branch on the origin remote. How can I do this? I tried @{o}
, but that doesn't work, and I cannot find this syntax anywhere in the git alias docs. I derived my answer from @sschuberth's comment in this answer, but I have not found much documentation otherwise.
Update I found a close solution, but it uses a bash argument instead of a git alias:
incoming = !git fetch && git log --pretty=oneline --abbrev-commit ..$1
The disadvantage here is that I cannot leverage the auto-completion provided by git and it does not automatically compare my local branch against that of my remote origin
repository.