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.
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.
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.
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.
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
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:
If you want to show the actual date, rather than a relative time then replace %(cr)
with %(ci)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With