3 ms·
Staging (and committing?) parts of a hunk is cool and I have done this many times myself. However, I am always uncomfortable with it because I am unsure how to
by sigjuice 7y ago
Staging (and committing?) parts of a hunk is cool and I have done this many times myself. However, I am always uncomfortable with it because I am unsure how to incorporate it within the overall workflow. I'd like each commit of mine to at least compile and pass some tests.
- gpderetta 7y agoThe custom buid system we use at $WORK can build and run tests from the index (or any git revision really) specifically to facilitate fine grained commits.
- useragent86 7y agoThe easiest way to do this is to, first, stash all the changes (by pressing "zz" in a magit-status buffer). Then expand the view of that stash's hunks, and press "a" on the hunks or lines you want to apply to the working tree (which does not pop the stash; the stash remains untouched). Run your tests, and when you're ready, stage them to the index and commit them. Then proceed to the next part of the stash that you want to test and apply. It's only a few keystrokes in Magit.
- iLemming 7y agoSo what's the problem? Commit often, make a bunch of commits. Or commit into the same commit over and over (<c e> - extend). Then depending on level of granularity you can either group related things together, or break one big commit into a bunch of smaller ones. Rebasing with Magit is a joy, it feels like you're a tailor and you just need to cut the fabric into nice pieces, and if sometimes things get too big or too small, you can always quickly fix it. And even when it feels that you accidentally ruined everything, you can always look at the reflog and un-ruin everything back to normal.
- RustyRussell 7y agoI agree: what I often want is stash of selective parts, so I can test the current stuff before commit.
- celeritascelery 7y agoMagit supports this as well. In fact you can stash the index and working tree separately. Even CLI got cant do that.