Get a list of all git commits, including the '

2020-02-16 05:35发布

Let's say that I have a graph like this:

A---B---C---D (master)
     \
      \-E---F (HEAD)

If I do git log --all --oneline, I will get all six of my commits.

But if the graph is

A---B---C---D (master, HEAD)
     \
      \-E---F

I will not see E and F. Can I get git to tell me all the commits, including those on branches which are not named?

Thanks

标签: git git-log
10条回答
走好不送
2楼-- · 2020-02-16 06:13

When I tackle this issue I use the following command:

git reflog |  awk '{ print $1 }' | xargs gitk

This lets me visualise recent commits which have become headless.

I have this wrapped up in a script helper called ~/bin/git-reflog-gitk.

查看更多
闹够了就滚
3楼-- · 2020-02-16 06:16

Like @Kieran 's Answer, but for the console: git log --oneline --all --graph --decorate $(git reflog | awk '{print $1}')

查看更多
祖国的老花朵
4楼-- · 2020-02-16 06:17

Try:

git log --reflog

which lists all git commits by pretending that all objects mentioned by reflogs (git reflog) are listed on the command line as <commit>.

查看更多
冷血范
5楼-- · 2020-02-16 06:18

If you use Git Extensions GUI it can show you a graphical visualization of dangling commits if you check "View -> Show reflog references". This will show dangling commits in the tree, just like all other referenced ones. This way it is way easier to find what you are looking for.

See this image for demonstration. Commits C2, C3, C4, and C5 on the image are dangling but still visible.

查看更多
登录 后发表回答