5 ms·
I had a recent epiphany about staging, which is that it really starts making sense if you stage as you go. Let's say you want to write small feature X, and it
by tsm 10y ago
I had a recent epiphany about staging, which is that it really starts making sense if you stage as you go.
Let's say you want to write small feature X, and it truly makes sense for X to be a single commit. But doing X involves changing around both Y and Z. Git makes the following workflow easy:
* Fiddle around until you get Y working how you want it
* Stage it
* Fiddle around trying to get Z to work. Try something experimental. Nope, that's not you want it. `git checkout .` Try again.
You don't have to worry about only blasting away the failed Z attempt while preserving Y—since Y is staged, it's easy to keep around.
- komali2 10y agoTechnically the same metaphor can be used for "commit" if we assume you stage the one thing and commit that one thing. Now look through the same workflow again but replace "stage" with "stage it and commit it."
- agentgt 10y agoYou can also use shelve in mercurial. I have never needed to use it on git though because of staging/cheap branches.
- krupan 10y agoBut why stage when you can just commit? You can use rebase -i to modify that commit later if you need.