My preferred way to use Git is on the command line. I have a set of Git command sequences that I use all the time and that I know by heart but are a nuisance to type out every time and a set of command sequences that I need regularly but have to look up all the time. In order to improve my personal Git user experience I created belly.
belly is a cli-tool that provides a better user experience for some common Git command sequences:
Commit & Push
When working on a personal project or on a feature branch within GitHub Flow, I do this all the time:
git commit -m "my commit message" git push
That’s a lot of typing for something I do tens of times a day.
belly combines this into one command:
belly c my commit message
Tip: instead of typing
belly you can just type
Git Checkout Branch Or Create And Checkout
I create branches for features, bug fixes and hot fixes all the times. I also often have to switch between branches.
belly combines switching and creating-and-switching into one command. So instead of:
git checkout my-branch
git checkout -b my-branch
I can just do:
belly s my-branch
belly will switch to
my-branch if it exists and it will create-and-switch to
my-branch if it doesn’t exist yet.
Set And Delete Tags Locally And On Remote
When you set a version tag you typically want it set in the local and the remote repository. belly allows you to do that with:
belly t v1.0.0
belly can also delete those tags for you:
belly t v1.0.0 -d
Rename A Branch Locally And Remote
This is one of those Git commands I always have to look up. How do I rename a branch again and why is the command to rename it on the server so different?
Anyway, no need to break out Google for that anymore. Just:
belly n my-new-branch-name
and it will rename your local branch as well as the corresponding remote branch for you.
There are a couple ways to squash your feature branch commits. If you want to
squash everything down to master and add a commit message you can use belly’s
belly q my commit message
Force-Push The Right Way
When you work with rebasing and squashing in order to keep your Git history
legible you have to force-push in your feature branches regularly. Rather than
--force-push it is recommended to use
--force-push-with-lease which is
an awkwardly named flag that does not allow you to force-push if the remote
branch has been updated by somebody else. This should be the default.
With belly you can use:
To force-push-with-lease your current branch state.
If you think any of these convenience methods would be useful to you, feel free to get belly. PRs are welcome, if discussed previously in an issue.
I will be improving belly over time and add more features if I think it would be useful.