63

我想看到git log输出中的所有存储。有谁知道是否有办法做到这一点?

编辑:我想查看日志中的所有提交——包括存储提交。我尝试了命令:

git log --date-order --all

但它只返回最顶层的存储。我也希望看到代表其他存储的提交。

4

8 回答 8

52

您可以使用git stash list. 也许您可以编写一个脚本来显示两者git stash listgit log并将其与别名一起使用。

于 2013-02-20T20:32:44.157 回答
46

我来这里是为了和@jbialobr 做同样的事情,在阅读了以前的答案后,我做了更多的挖掘,并提出了以下内容。

@msmt 的答案为您提供了存储日志,您可以使用它来获取要在 git 日志中使用的哈希。

git reflog show --format="%h" stash只为您提供所有存储的哈希值,然后可以将其传递给 git log 命令,例如

git log --date-order --all $(git reflog show --format="%h" stash)

我个人现在使用的完整命令是

git log --oneline --graph --decorate --all $(git reflog show --format="%h" stash)

在 centos 上的 git 版本 2.5.1 上测试

于 2016-03-14T16:53:31.223 回答
19

不明白你的意思。stash 是一个分支,您可以使用git log -g stash.

于 2013-02-20T20:11:20.943 回答
7

另一种简单的方法是git reflog show stash

于 2015-03-05T16:37:35.663 回答
2

完整命令:

git log --oneline --graph --all $(git stash list --format="%H")

藏匿处的清单:

git stash list --format="%H"

于 2019-02-21T13:29:25.613 回答
2

获取包含所有内容的树形图:所有分支,所有存储在您的指尖......


扩展来自 SicoAnimal 的一个超级有用的答案,因此您不必输入所有这些内容(对于没有任何 Git UI 的远程 SSH 会话尤其有用) ...


1.设置git别名:

# Short and sweet: hashes and graph with all branches and stashes
git config --global alias.l \
    '!sh -c '"'"' git log --oneline --graph --all --decorate $(git reflog show --format="%h" stash --) '"'"' '

# Same as above + dates and emails
git config --global alias.ll \
    '!sh -c '"'"' git log --graph --all --date=format:"'"%Y-%m-%d %H:%M"'" --pretty=format:"'"%C(yellow)%h%Creset%C(auto)%d%Creset %C(cyan)%cd%Creset %s %C(green)(%ce)%Creset"'" $(git reflog show --format="%h" stash --) '"'"' '

2.使用别名

# Short and sweet: hashes and graph with all branches and stashes
git l

# Same as above + dates and emails
git ll

3. 甜蜜的结果

请注意,您可以看到所有存储,而不仅仅是给定提交上的最新存储(用箭头显示)。

在此处输入图像描述


改进空间:

# In case there are no stashes you get one-liner error message.
# The rest works as expected. Not sure how to fix it.
me@mymachine:~/projects/experiment/latest-angular-ten$ git l
fatal: bad revision 'stash'
* 00a696b (HEAD -> master) initial commit


参考:

如何使用带参数的嵌套命令创建 Git 别名?

于 2020-12-18T15:16:34.317 回答
2

对于 git 版本 2.2.3 或更高版本,您可以简单地--reflog使用git log.

git log --graph --oneline --all --reflog

此外,它还显示悬空提交

于 2022-01-21T03:52:30.597 回答
0

如果您负担得起图形 GUI,请查看gitk.

它以视觉上不吸引人但非常紧凑和有用的形式向您显示分支、标签、远程分支存储等。它通常与包管理器中的“git”包一起提供,如果你也有“tk”(它使用的 GUI 工具包),它也可以工作。

于 2019-02-12T08:01:14.487 回答