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
project/some/file
project/another/file

# efa1d6pd add a feature
## John Doe
project/blah.txt
project/another/file

# 74417d1d something else
## Hisham Muhammad
project/another/file
something/else/entirely
spec/01-test_another_file_spec.lua

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!


Follow

🐘 MastodonRSS (English), RSS (português), RSS (todos / all)


Last 10 entries


Search


Admin