我希望在git log
输出中看到所有的存储区。有人知道是否有办法实现吗?
编辑:我想要在日志中看到所有提交记录,包括stash提交记录。我尝试了以下命令:
git log --date-order --all
但它只返回最顶部的stash。我想看到代表其他stash的提交。
您可以使用git stash list
来显示所有的存储进度。也许您可以编写一个脚本来展示git stash list
和git log
,并将其与别名一起使用。
我来这里是想要做与 @jbialobr 相同的事情,读了之前的回答后进行了更深入的挖掘,得出了以下结果。
@msmt 的答案提供了存储库中所有备份的日志,您可以使用此信息获取哈希值并在 git 日志中使用。
git reflog show --format="%h" stash
可以给出所有备份的哈希值,然后可以将其传递给 git 日志命令,例如:
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
不确定您的意思。stash是一个分支,您可以使用git log -g stash
列出所有的“stash”。
stash
是 refs/stash
的缩写,它是所有存储头的列表。-g
(或 --walk-refs
)告诉 log
遍历引用列表中的项目,而不是从每个存储提交的修改历史记录。 - Joshua Goldberggit reflog show stash
命令。git log
命令的输出中包含所有存储。 - jbialobrgit log
的 --reflog
选项。git log --graph --oneline --all --reflog
此外,它还显示了悬挂提交。
获取包含所有分支和所有存储的树状图:
扩展自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 stash list --format=%H
(如上面的评论中由 @tangle 建议的)当没有存储时就不会出现问题。 - undefinedgit stash list
。 - undefined完整命令:
git log --oneline --graph --all $(git stash list --format="%H")
这里的“list of heads of stashes”指的是暂存列表的头部:
git stash list --format="%H"
请注意,以上命令与Git相关,用于检索和显示版本控制的信息。
gitk
。git stash list --format=%H
。 - undefined
git reflog show --format="%h" stash | xargs git show
- joachim