0xc0de
0xc0de

Reputation: 8317

what are possible ways of referring to a git stash?

In

git stash show stash@{x}

what values can x take(apart from the whole numbers pointing to the serial number of the stash)?

Upvotes: 2

Views: 103

Answers (2)

VonC
VonC

Reputation: 1328522

The only values I know of are the one listed by:

git stash list

Ie the "whole numbers" you are referring in your question (0, 1, 2, ...), or time-based syntax:

git stash man page:

The latest stash you created is stored in refs/stash; older stashes are found in the reflog of this reference and can be named using the usual reflog syntax
(e.g. stash@{0} is the most recently created stash, stash@{1} is the one before it,
stash@{2.hours.ago} is also possible).

If so, the list of values are part of the ones specified in git rev-parse, mainly inspired from the following two categories:

  • 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}) to specify 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.

  • A ref followed by the suffix @ with an ordinal specification enclosed in a brace pair (e.g. {1}, {15}) to specify 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/<ref>).

Upvotes: 2

kan
kan

Reputation: 28981

git show stash@{0} shows you the stash entry's sha1, should be absolutely unique.

Upvotes: 0

Related Questions