One useful feature Git has had since 1.7.0 is the ability to refer to
the branch that another one is tracking using [branch]@{upstream}
notation. I’ve found this especially handy while working on projects
with multiple committers.
When working on projects with multiple committers, I usually set my
local copies of the integration branches to track the branch from the
canonical repository (which I typically have as the upstream remote)
instead of tracking the copy of the integration branch from my fork of
the repository. By doing this I can quickly bring my local copy of
the tracking branch up to date with the canonical repository.
1 2 3 4 5 6 7 8 9 10 11 12 | |
Normally I don’t use the 2.7.x@{upstream} form, however. Instead, I
use @{u}, which takes advantage of the shorter form, as well as
@{u} and @{upstream} defaulting to the current branch if none is
specified. git reset --hard @{u} is fairly easy to type, and
trivially aliased to use as a shortcut to make sure the integration
branch is up to date before merging.