4 ms·
Why would I use Stacked Git rather than Git’s fixup/interactive rebase dance? For example: git commit -m "one thing" # commit hash: deadbeef git
by Hackbraten 5y ago
Why would I use Stacked Git rather than Git’s fixup/interactive rebase dance?
For example:
git commit -m "one thing"
# commit hash: deadbeef
git commit -m "other thing"
# commit hash: badf00d
(working on one thing)
then:
git commit --fixup deadbeef
(working on the other thing again)
then:
git commit --fixup badf00d
And in the end, when I’m ready to roll each patch into one commit, respectively:
git rebase -i --autosquash
I do realize that Stacked Git allows me to switch between patches. Which is nice because regular Git wants me to type in SHAs for --fixup.
But I’m not sure I’d take on a new tool dependency just for that. What are other benefits of Stacked Git? Just wondering if I’m missing something.
- epage 5y agoThe main reason I've heard of people using tools like this is so people can review a commit at a time (a lot of review tools don't handle this well) and CI runs on each commit. Generally, it sounds like people are simulated Phab with these tools which is trying to simulate the email patch workflow.
- gorset 5y agoWe use gitlab and review a commit at a time and do CI runs on each commit in the MR branch. Just plain git with the fixup/interactive rebase dance. Gitlab is not optimized for this workflow, but it’s liveable. Gitlab-runner can execute any shell commands, so it’s easy to just loop through all the commits and run bazel test. Gitlab has improved lately and it’s now easier to review each commit in a MR, but you can sense that most of the PM attention is on the single commit/squash everything MR workflow.
- Too 5y agoParent example above doesn't change any of that. Don't be fooled by the squash in rebase -i --autosquash, there will still be a series of commits.
- jpgrayson 5y agoWith the kind of git workflow you describe, bringing StGit into your tooling/workflow may not be worthwhile. I'd say if you wanted to do these kinds of stack manipulations a little bit faster or with a little less cognitive overhead (e.g. named patches vs SHA1 hashes), then investing in StGit might pay off. I generally would agree that using StGit isn't going to be a slam-dunk win for someone who already has a capable workflow using interactive git rebase.
- Hackbraten 5y agoGot it. Thank you for clarifying.
- juped 5y agoCan you explain what your tool does to someone who knows what an interactive rebase is? I don't get much more from your blurb than "we reimplemented interactive rebase for some reason", but I'm sure you do something different or unique...
- juped 5y agoif the commit name is more readily at hand, just name the commit "fixup! whatever". --fixup just does this for you since references are shorter and easier to type (it doesn't have to be a hash, it can be --fixup HEAD~2 or something).
- urxvtcd 5y agoYou can also use part of commit message to find that commit, so if you want to fixup "Refactor foo", you can run git commit --fixup :/foo
- Hackbraten 5y agoNice!
- lightgreen 5y ago> Why would I use Stacked Git rather than Git’s fixup/interactive rebase dance? Yeah, dance is good analogy. Lot of training, one little mistake and it is ruined. For example, if you need to introduce a change in commit "one thing" which would require merge conflict resolving in "other thing", with stgit it would be much easier than with fixup/autosquash. Or another example. You need to put away "other thing" for a while, and work with "one thing" for an hour, and then apply/fix "other thing". Another set of git tricks needed. > But I’m not sure I’d take on a new tool dependency just for that. If you are happy with git, nobody forces you to. By the way, you don't have to use stgit all the time. I usually just use git, but when a change in a branch requires changing of previous commit, I simply do: stg init; stg uncommit; stg pop. It's easy to convert local repo state to and from stgit.
- Hackbraten 5y agoGood points.