Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the creation date of a stash

Tags:

git

git-stash

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.

like image 790
Jason Lawton Avatar asked Mar 21 '13 15:03

Jason Lawton


People also ask

How do I find my stash date?

If you want to show the actual date, rather than a relative time then replace %(cr) with %(ci) . Show activity on this post. git show stash@{0} also prints out the date, along with the other information.

How do I see my git stash history?

One you have identified the entry in which you are interested, you likely want to see what is in that stash. This is where the git stash show command comes in. This will display a summary of file changes in the stash.

How do I view stash logs?

The Git stash list command will pull up a list of your repository's stashes. Git will display all of your stashes and a corresponding stash index. Now, if you wish to view the contents of a specific stash, you can run the Git stash show command followed by stash@ and the desired index.


2 Answers

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 
like image 115
Igor Avatar answered Oct 22 '22 06:10

Igor


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

like image 45
Lee Netherton Avatar answered Oct 22 '22 05:10

Lee Netherton