hisham hm

🔗 A nice summary of Git commits with files when rebasing

When you’re making a large interactive rebase, it’s useful to see what files each commit touches.

Here’s a nice trick. Take the list of commits from `git rebase -i` and save it into a text file, `commits.txt`, which should look something like this:

pick aef18c84 fix something
pick efa1d6pd add a feature
pick 74417d1d something else

then run this:

(cat commits.txt | while read x commit rest; do echo; echo "#" $commit $rest; git show $commit --pretty=format:'## %an' --name-only; done ) > commits.md

This will generate a file called `commits.md`, with contents like this:

# aef18c84 fix something
## Hisham Muhammad

# efa1d6pd add a feature
## John Doe

# 74417d1d something else
## Hisham Muhammad

Keeping this `commit.md` open side-by-side to an interactive rebase session makes it a lot easier to quickly glance which commits touch the same files, which greatly reduces the changes of conflicts when moving commits around. Plus, using hash signs and the .md extension makes the whole thing even easier to read, when your text editor has support for highlighting Markdown files!


🐦 Twitter🐘 MastodonRSS - posts in English, posts em Português, todos / all

Latest posts


Admin area