Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
386 views
in Technique[技术] by (71.8m points)

gitk - How to show only given commits (logically same as `git log --no-walk`)

I have a huge history and I'm only interested in given commits (say I have a list of 10 commit sha1s). How to start gitk, that is

gitk --SOMETHING sha123 sha234 sha345 ...

so that only the given commits are rendered in gitk? I know that I can do similar thing with

git log --oneline --no-walk sha123 sha234 sha345 ...

but git log --no-walk doesn't want to take --graph. In addition, I'd prefer gitk so that I can view each commit a bit easier. If one or more of the above commits include merge with one or more of the given commits, I'd like to see graph lines between the commits. Basically I'm asking for something like --simplify-everything-but-listed-commits.

Another good solution would be if somebody can point out how to run gitk like

gitk --simplify-by-decoration --never-simplify-listed-commits sha123 sha234 sha345 ...

because that would render some extra but still process whole history for real. Of course, the flag --never-simplify-listed-commits doesn't exist. The --simplify-by-decoration ends up NOT rendering any of the given SHA-1s because those do not match any branch or tag.

I also tried hacks such as

gitk sha123..sha123 sha234..sha234 ...

because it seems that gitk is willing to render only given commits with that syntax. However, that only seems to work only for one range at a time. I'd much prefer rendering all commits in a single view.

question from:https://stackoverflow.com/questions/65848193/how-to-show-only-given-commits-logically-same-as-git-log-no-walk

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

One way could be to create a reference for each of these commits, and use the --decorate-refs= option of git log.

For example :

  • create one branch dec/{xx} reference pointing at each of the 10 commits,
  • run :
git log --all --oneline --graph --decorate-refs=refs/heads/dec --simplify-by-decoration
  • delete all branches under dec/

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...