When running git commit --fixup=beefca7e or when referencing a previous commit in a commit message, I have to use the mouse in a clumsy workflow. I use bash:
- Open a new terminal tab/window/pane.
git log --oneline --graph.¹- Scan through the list to find the relevant commit sha.
- Grab the mouse, select the sha, copy it to the clipboard.²
- Move back the the pane where I was working and paste it there.
This works. But I suspect this can be done much easier.
Are there commandline tools, scripts or git-addons out there that allow me to quickly filter through the commits and copy the sha of a selected entry? Is my workflow wrong(or naive), and did I miss an important git-feature somewhere?
Bonus for being able to use this in vim too, since that is my editor to edit commit messages. Bonus for copying the short sha instead of the full one.
- ¹ I have a somewhat more complex alias for this named
git lg. - ² xclip/gnome/clipboard manager is configured to auto-copy-on-select. Otherwise ctrl-c/cmd-c or so. Pasting is middle-mouse-button. Saves a few commands but still suboptimal. I'd rather not use the mouse at all and omit most steps.
^2somewhere rather than justHEAD~7. Linear counting only works if you're on a linear piece of the commit graph. :-) You can also use commit message searching such as:/foo. In the end though I tend to just use cut and paste of the hash ID.tig?tigandgitgmostly when I have to explore the history. Bothtigand gitg, however, have no easy way to copy the commit sha AFAIK, which means I have to use tig or gitg over the common git-commands to commit, write messages, write fixups etc. Maybe I'll reconsider this if there's no easy way to "get a git sha" alltogheter.