Perché usare 'stash @ {n}'?

2

git stash apply stash@{n} contiene un numero di caratteri difficili da digitare e ripete alcune informazioni.

C'è un motivo per ripetere il stash e usare il segno-at e le parentesi invece di qualcosa di più semplice da digitare, ad esempio git stash apply n , ad esempio?

    
posta user5253365 11.09.2015 - 18:28
fonte

1 risposta

8

Questa è in realtà una semplice istanza di una sintassi molto più generale per specificare i riferimenti simbolici (in pratica, tutte le cose in .git/refs ). Dall'attuale documentazione di git sulle revisioni :

<refname>@\{<date>\}, e.g. master@{yesterday}, HEAD@\{5 minutes ago\}

A ref followed by the suffix @ with a date specification enclosed in a brace pair (e.g. {yesterday}, {1 month 2 weeks 3 days 1 hour 1 second ago} or {1979-02-26 18:30:00}) specifies the value of the ref at a prior point in time. This suffix may only be used immediately following a ref name and the ref must have an existing log ($GIT_DIR/logs/<ref>). Note that this looks up the state of your local ref at a given time; e.g., what was in your local master branch last week. If you want to look at commits made during certain times, see --since and --until.

<refname>@\{<n>\}, e.g. master@{1}

A ref followed by the suffix @ with an ordinal specification enclosed in a brace pair (e.g. {1}, {15}) specifies the n-th prior value of that ref. For example master@{1} is the immediate prior value of master while master@{5} is the 5th prior value of master. This suffix may only be used immediately following a ref name and the ref must have an existing log ($GIT_DIR/logs/<refname>).

@\{<n>\}, e.g. @{1}

You can use the @ construct with an empty ref part to get at a reflog entry of the current branch. For example, if you are on branch blabla then @{1} means the same as blabla@{1}.

@\{-<n>\}, e.g. @\{-1\}

The construct @\{-<n>\} means the <n>th branch/commit checked out before the current one.

<branchname>@{upstream}, e.g. master@{upstream}, @{u}

The suffix @{upstream} to a branchname (short form @{u}) refers to the branch that the branch specified by branchname is set to build on top of (configured with branch.<name>.remote and branch.<name>.merge). A missing branchname defaults to the current one.

È molto comprensibile il motivo per cui la sintassi stash@{0} sembra inutilmente ornata se l'hai vista solo nel contesto dei riferimenti di stash.

    
risposta data 11.09.2015 - 18:58
fonte

Leggi altre domande sui tag