git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: How to display "HEAD~*" in "git log"

From
Kkostix@bswap.ru <kostix@bswap.ru>
Date
Jul 6, 2022, 12:38 UTC
Message-ID
<20220706123811.dwbuinnbtxftorae@carbon>
In-Reply-To
<a1e53e52-cb08-bbff-f58a-391932707fb7@mails.ucas.ac.cn>

By the way, you can consider "going more interactive" with the approach which involves scripting. For instance, you can use any of the "fuzzy finders" such as the venerable fzf [1] to interactively select a commit to rebase - something like

  $ git log --oneline -50 | fzf | cut -d ' ' -f 1

would produce the log of the last 50 commits, allow you to interactively select a commit of interest by typing some of the characters of its message and/or hash and then print the selected hash.

This can be easily combined with rebasing: for instance, if you have the above encantation available as an alias named "select" or a custom script named "git-select", you could do

  $ git rebase -i $(git select)~
to not even copy or memorize anyting.
I, for one, routinely use fzf to pick a branch for checkout.
1. https://github.com/junegunn/fzf
Previous: wuzhouhuiNext: Jeff King
Message 5 of 11 in “How to display "HEAD~*" in "git log"”
  1. wuzhouhuiJul 5, 2022
  2. Konstantin KhomoutovJul 5, 2022
  3. Konstantin KhomoutovJul 5, 2022
  4. wuzhouhuiJul 5, 2022
  5. kostix@bswap.ruJul 6, 2022
  6. Jeff KingJul 6, 2022
  7. Konstantin KhomoutovJul 6, 2022
  8. Jeff KingJul 6, 2022
  9. Konstantin KhomoutovJul 6, 2022
  10. Jeff KingJul 7, 2022
  11. Junio C HamanoJul 6, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.