62

In the book "Git: Version Control for Everyone. Beginner's Guide" on page 69 there is a suggestion: "As an alternative to git pull, we can also use git fetch followed by git merge @{u}".

What does @{u} mean here?

A search in Google for git merge @{u} provides a link to this page https://mislav.net/2013/02/merge-vs-rebase/ where @{u} can also be found.

Dave Powers
  • 2,051
  • 2
  • 30
  • 34
abg
  • 2,002
  • 7
  • 39
  • 63

1 Answers1

76

It is a shortcut to refer to the upstream branch which the current branch is tracking. So for instance if you're on branch topic/fix_blub which is tracking origin/topic/fix_blub then git merge @{u} does the same thing as git merge origin/topic/fix_blub.

@{u} is part of Git's mini-language for locating revisions, which is described in detail here.

0xC0000022L
  • 20,597
  • 9
  • 86
  • 152
Peter
  • 3,619
  • 3
  • 31
  • 37
  • 1
    how do I print the value of @{u}? – Philip Rego Jun 27 '19 at 20:35
  • 3
    @PhilipRego `git rev-parse @{u}` – seeker_of_bacon Dec 04 '19 at 09:06
  • 2
    when i try to use `git reset --hard @{u}` the console doesn't execute the command but starts a new line with `>>` at the start (as if i had an open string going) I'm Using git on Windows in powershell and i noticed a few times that i need to use different control characters than other people (e.g. ~ instead of ^) is this the same case here? do you know anything about that? – Stefan Lippeck Nov 23 '21 at 08:01
  • 2
    @StefanLippeck see [this answer](https://stackoverflow.com/a/61490618/184546) for how to escape it in PowerShell. – TTT Aug 06 '22 at 03:54