Home > Software design >  What does "master^@" mean/represent in Git?
What does "master^@" mean/represent in Git?

Time:08-18

I was reading the documentation for git diff and stumbled across the following section:

A convenient way to produce the desired set of revisions is to use the ^@ suffix. For instance, if master names a merge commit, git diff master master^@ gives the same combined diff as git show master.

I cannot seem to understand what master^@ means here.

CodePudding user response:

The documentation for git-rev-parse(1) describes that notation:

Other <rev>^ Parent Shorthand Notations
       Three other shorthands exist, particularly useful for merge commits,
       for naming a set that is formed by a commit and its parent commits.

       The r1^@ notation means all parents of r1.

       The r1^! notation includes commit r1 but excludes all of its parents.
       By itself, this notation denotes the single commit r1.

       The <rev>^-[<n>] notation includes <rev> but excludes the <n>th
       parent (i.e. a shorthand for <rev>^<n>..<rev>), with <n> = 1 if not
       given. This is typically useful for merge commits where you can just
       pass <commit>^- to get all the commits in the branch that was merged
       in merge commit <commit> (including <commit> itself).

       While <rev>^<n> was about specifying a single commit parent, these
       three notations also consider its parents. For example you can say
       HEAD^2^@, however you cannot say HEAD^@^2.

So, in summary, also in that manpage:

       <rev>^@, e.g. HEAD^@
           A suffix ^ followed by an at sign is the same as listing all
           parents of <rev> (meaning, include anything reachable from its
           parents, but not the commit itself).

That is why you can pass it to git diff instead of listing all parents.

  •  Tags:  
  • git
  • Related