Brondahl
Brondahl

Reputation: 8557

git reference for current branch's remote branch

I can indirectly reference "the current commit" with HEAD.

I can indirectly reference "the commit before otherCommit" with otherCommit~ or otherCommit^ (subtleties relating to merge commits IIRC)

Is there a way that I can indirectly reference "the branch which the currently active branch is tracking".

Usages would include git reset --hard <magicReference> which discards local changes, and local commits to the current branch, without needing to type the name of the current branch.


Regarding any warnings about reset --hard or detached HEADs ... I do know exactly what I'm doing and none of those concerns apply. Please assume that what command I want to run that happens to references the remote branch that my current branch tracks is genuinely what I want to run.

Upvotes: 1

Views: 233

Answers (1)

Quentin
Quentin

Reputation: 63124

You're looking for HEAD@{upstream}, also known as @{upstream}, also known as @{u}.

Upvotes: 4

Related Questions