by phs2501 · 7y ago · 0 comments
Personally, I use staging area all the time to create a curated set of commits that make logical sense when putting them up for review.
My workflow is generally to keep a very messy history of `XXX` commits until I am happy with what I've come up with. Then reset back to the branch point and using the staging area to build up logical changesets.
I don't care about the history of my coming up with the solution, I care about presenting the solution in a way that makes sense to reviewers, including future me.
Later on, if I notice that I messed something up, I'll create a fixup commit and do an interactive rebase to squash it back into the correct commit.
The staging area is basically a half-baked, special commit that is easy to do manipulation on but hard to figure out what its actual state is (e.g., show me only the diffs that are in the staging area, or let me figure out what the hell is actually going on if I'm doing a complicated rebase). You know what would be better? Turn the staging area into a full, real commit and lower the friction of editing unpushed history to make it easy to move patch hunks in, out, and between these commits. It would help people who want commits to be atomic and therefore break WIP changes into multiple commits before publishing them for review.
And how would you stage & commit only a portion of the changes made to a file?
(Like the parents, I use the staging area daily, and I am quite thankful for its existence.)
I wouldn't. That code is untested, and I have a thing against committing untested code.
Git stash -p, on the other hand, allows me to select what code should be left in the working directory for testing, with no need for a staging area.
git commit those three files
That operation is still not implemented in git/fs, but it's planned.Take a look at the research by the gitless folks: https://spderosso.github.io/oopsla16.pdf, https://gitless.com/
So yeah, feel free to leave it out of your implementation; it doesn't seem like something that'd fit into the plan9 mindset anyway. But it is removing a very useful tool to some people.
Sometimes, you want to have a temporary snapshot, but not a commit.
So I write some code, it works, but I'm thinking of trying some things out. I stage the working code and make more diffs. Now I can have my editor show the diffs between my stage and my new changes. And I can easily rollback individual files or re-stage some more files.
Until I am satisfied. And now decide to make a commit.
I could just make them all commits, and then do a interactive rebase as well. And I do that too. But sometimes the staging area is just simpler and quicker. With git status I can see it at a glance. Etc.
Truly jumped the shark.
This study design is a real problem -- even after I have read the paper, I am not convinced that I should be using gitless. Their graph looks science-y, but the small sample size and non-representative experiment design means the conclusion do not apply to my work.
Reading this paper is reading a DB benchmark which only used rows with two integer fields in all their tests. Sure, it is interesting reading, but unless your workflow is exactly that, it is useless in real life.
(Disclaimer: it is entirely possible that gitless is better than git in all workflows, not just the one described in the paper. But even if it is the case, I would not know about it, at least not from the gitless site.)