【发布时间】:2013-02-05 23:45:46
【问题描述】:
我想查看git log 输出中的所有存储。有谁知道有没有办法做到这一点?
编辑:我想记录所有提交。我使用命令
git log --date-order --all
但它只返回最顶层的存储。我希望看到代表其他存储的提交。
【问题讨论】:
我想查看git log 输出中的所有存储。有谁知道有没有办法做到这一点?
编辑:我想记录所有提交。我使用命令
git log --date-order --all
但它只返回最顶层的存储。我希望看到代表其他存储的提交。
【问题讨论】:
您可以使用git stash list 显示您的所有藏匿处。也许您可以编写一个脚本来同时显示git stash list 和git log 并将其与别名一起使用。
【讨论】:
我来这里是为了和@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 上测试
【讨论】:
git reflog show --format="%h" stash | xargs git show
不确定你的意思。 stash 是一个分支,您可以使用git log -g stash 列出所有存储。
【讨论】:
stash 是所有存储头列表的refs/stash 的缩写,-g(或--walk-refs)告诉log通过参考列表中的项目,而不是从每次存储提交中跟踪修改历史。
另一个简单的方法是git reflog show stash
【讨论】:
git log 命令的输出中包含所有存储。
I would like to see commits that represent other stashes. 如果git log --all 不适合你,那么我将不得不支持@robinr 所说的“不确定你的意思”。
完整命令:
git log --oneline --graph --all $(git stash list --format="%H")
藏匿处列表:
git stash list --format="%H"
【讨论】:
要获得包含所有内容的树形图:所有分支、所有存储都触手可及...
扩展 super-useful answer from 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
参考资料:
How to create a Git alias with nested commands with parameters?
【讨论】:
如果您负担得起图形 GUI,请查看 gitk。
它以一种视觉上不吸引人但非常紧凑和有用的形式向您显示分支、标签、远程分支存储等。它通常与包管理器中的“git”包一起提供,如果你也有“tk”(它使用的 GUI 工具包),它也可以工作。
【讨论】: