Hidden gem - stgit
I just discovered stacked git which is an alternative ui for git, and am very impressed. It solves a lot of headaches I have been having with git and I feel like it may be a better user interface for people who like careful commits.
Maybe it doesn’t get attention is deserves due to (in my opinion) a hard to understand website and little promotion, so to help spread the word here is my 2 cents.
- It is like a lightweight alternative to one branch per feature.
- It is very nice for when usually you only do one commit per pull request.
- It good for when you are constantly testing combinations of features as it allows you to avoid creating all sorts of strange hybrid branches.
And an example:
All the stuff you are currently working on is a stack of changes:
+ feature1 + feature2 > workarounds
Notice the final patch in the list is my local work of hacky workarounds I wouldn’t want in any pull request. The tool makes it easier to enable or disable patches like these at a whim.
You can change what current feature you are working on, and easily update just that patch.
$ stg goto feature1 ... make changes to feature1 $ stg refresh # Save changes I just made in # the feature1 patch/commit.
When you go to a feature, it unapplies patches after it on the stack, so you can use the stack commands to change the patch order.
$ stg sink workarounds # Shift workarounds patch to the bottom # so it is active while we work # on different patches. $ stg goto feature2 # Now we can work on feature2 # with our workarounds enabled.
You can nicely edit the commit message of each feature or thing you are working with a single command:
$ stg edit feature1 # This would be a lot of # rebasing in normal git.
If we want to start a new feature:
$ stg new feature3 do your work... $ stg refresh # Save your work.
When you are done you can publish them to a branch and they all appear as a normal clean git history with just the patches/commits you want:
$ stg hide workarounds $ stg publish -b finished-branch
Or you can send them as a set of diffs to your friend.
$ stg send-email feature1 feature2 # works great with sr.ht
That’s about it… remember stg is just a different UI for git, the repository is still a normal git repository with some additional metadata you can ignore.
Most things can be done with plain git, but this makes some things that are 2 or 3 commands requiring temporary branches much shorter and easier. Stgit saves you tedious rebasing and ammending of past commits while keeping a clean git history.