git 获取存储的创建日期

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15551618/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 15:48:01  来源:igfitidea点击:

Get the creation date of a stash

gitgit-stash

提问by Jason

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

有没有办法知道什么时候创建了一个 stash?

git stash listonly lists the stashes, and git stash show XXXXXXshows all the files and changes, but not the dateof the stash creation.

git stash list仅列出存储,并git stash show XXXXXX显示所有文件和更改,但不显示存储创建日期

回答by Igor

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

回答by Lee Netherton

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

您可以使用它--pretty=format来实现这一点。例如,这会生成一个包含相对时间的存储列表:

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 ~/.gitconfigfile, so that I can bind it to a simple slcommand:

我在[alias]我的~/.gitconfig文件部分设置了这个,以便我可以将它绑定到一个简单的sl命令:

[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 logand reflog)

(你可以看到我也有类似的标记logreflog

Here's what it looks like: git stash list

这是它的样子: git 存储列表

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

如果要显示实际日期,而不是相对时间,请替换%(cr)%(ci).

回答by bcmcfc

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

git show stash@{0}还会打印出日期以及其他信息。