Skip to main content
ertius.org

very partial git commits

magit is of course the best git client there is, in particular because of how easy it makes curating the index/staging area. You can select individual hunks and go down to marking individual lines for staging, and so I often end up spending a lot of time crafting a commit. A downside of this is that most of the time my index is in some very specific state and so if I want to commit something else, e.g. a typo fix or a dependency or something that's not super related to the current change, I can't easily do so - I would need to stash and add and commit and unstash, and so I basically never do.

Turns out someone thought of this and added a great new1 feature to git - -o / --only:

$ git add some_file.txt && git commit -o -m"add some_file.txt" some_file.txt

A should-not-have-been-surprising-to-me quirk is that it's filtering the index not the tree, and so you need to stage it first.

1

added 2006-02-05 16:08:01 -0800 to ... git-commit.sh link