Get the creation date of a stash

GitGit Stash

Git Problem Overview


Is there a way to tell when a stash was created?

git stash list only lists the stashes, and git stash show XXXXXX shows all the files and changes, but not the date of the stash creation.

Git Solutions


Solution 1 - Git

Try:

git stash list --date=local

It should print something like:

stash@{Thu Mar 21 10:30:17 2013}: WIP on master: 2ffc05b Adding resource

Solution 2 - Git

You can use --pretty=format to achieve this. For example, this produces a stash list that includes a relative time:

git stash list --pretty=format:"%C(red)%h%C(reset) - %C(dim yellow)(%C(bold magenta)%gd%C(dim yellow))%C(reset) %<(70,trunc)%s %C(green)(%cr) %C(bold blue)<%an>%C(reset)"

I have this set in the [alias] section of my ~/.gitconfig file, so that I can bind it to a simple sl command:

[alias]
        co = checkout
        lg = log --graph --pretty=format:\"%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset\" --abbrev-commit
        rl = reflog --pretty=format:\"%Cred%h%Creset %C(auto)%gd%Creset %C(auto)%gs%C(reset) %C(green)(%cr)%C(reset) %C(bold blue)<%an>%Creset\" --abbrev-commit
        sl = stash list --pretty=format:\"%C(red)%h%C(reset) - %C(dim yellow)(%C(bold magenta)%gd%C(dim yellow))%C(reset) %<(70,trunc)%s %C(green)(%cr) %C(bold blue)<%an>%C(reset)\"

(You can see that I also have similar markups for log and reflog)

Here's what it looks like: git stash list

If you want to show the actual date, rather than a relative time then replace %(cr) with %(ci).

Solution 3 - Git

git show stash@{0} also prints out the date, along with the other information.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJason LawtonView Question on Stackoverflow
Solution 1 - GitIgorView Answer on Stackoverflow
Solution 2 - GitLee NethertonView Answer on Stackoverflow
Solution 3 - GitbcmcfcView Answer on Stackoverflow