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.

share|improve this question
up vote 180 down vote accepted

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
share|improve this answer
1  
Can I add an option somewhere in my .gitconfig to make this the default display? – Trevoke Oct 31 '13 at 18:13
2  
@Trevoke Hm, not that I'm aware of. Best I could find was this nabble: git.661346.n2.nabble.com/… – Igor Oct 31 '13 at 18:22
4  
I prefer git stash list --date=relative. Worth noting is that the --date is coming from the git log command, not stash itself, see here for possible --date values: stackoverflow.com/questions/7853332/git-log-date-formats – thnee Oct 21 '14 at 15:09
6  
@Trevoke I added an alias [alias] stashlist = "stash list --date=local" to my ~/.gitconfig file – user848337 Dec 12 '14 at 16:38
1  
git stash list --date=short give you date only, in fixed width YYYY-MM-DD format that is easy to visually scan. – Tor Klingberg Jan 17 at 16:38

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

share|improve this answer
1  
Ah I was using the 6 character abbreviation, maybe that was the problem. I think it also threw an error when I tried that command, but I'm on windows, so that's a whole other problem :). – Jason Mar 21 '13 at 15:42
3  
Ah, Windows. Trying to use git on Windows usually leads me towards wanting to defenestrate my laptop ;) – bcmcfc Mar 21 '13 at 15:44
    
Doesn't appear to print the date with Git 2.8.3. – Elijah Lynn Jun 19 '16 at 14:16
    
@ElijahLynn I don't have a 2.8.3. to test on but it prints a full commit on 2.9 – bcmcfc Jun 20 '16 at 7:37

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).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.