Show HN: Gitbasher – A simple bash utility to make Git easy to use

4 months ago 10

Latest Release GitHub license Build Status

gitbasher logo

Simple bash utility that makes git easy to use

With gitbasher usage of git becomes more simple and intuitive. It helps speeding up the development process, making it more consistent reducing mistakes. This is a wrapper around the most used git commands with a cleaner interface. It uses bash git sed grep, curl and some built-in utilities.

commit example
GITB_PATH=/usr/local/bin/gitb && \ curl -SL https://raw.githubusercontent.com/maxbolgarin/gitbasher/main/dist/gitb -o $GITB_PATH && \ chmod +x $GITB_PATH

In Windows use wsl (enter wsl in terminal, read more) to enable Linux environment. Directory /usr/local/bin/ is not mandatory. If you get Permission denied, use sudo or put it to ~/.local/bin with adding it to PATH (how).

gitbasher is essential if you use git on the daily basis. Benefits you will get:

  • Development process will be faster because you will spend almost no time on git
  • No need to remember/google the exact names of commands and their parameters
  • Making the development process clearer by using conventional commits (manual or AI generated); gitbasher uses Conventional style of commits (example)
  • Making "advanced" commands like git rebase more user-friendly, so you will be able to unleash the full potential of the git system without any particular difficulties
  • Following the GitHub flow in the development process by simplifying the work with branches
push example

Just install gitbasher and use it in any git repository - run gitb in the terminal. It requires bash version 4 or higher.

Usage gitb <command> <mode>

  • gitb c for commit creation
  • gitb b n for branch creation
  • gitb pu for pulling from the remote
  • gitb p for pushing to the remote
  • gitb h to show all commands

Use gitb c help to get help about commit commands. You can get help with help for all other commands. To get a global help enter gitb. You can find all commands description in the documentation.

  • Select files to commit and create a message in the format: type(scope): message
  • AI-powered commits: Use gitb c ai to generate commit messages automatically based on your changes
  • There are a lot of modes for commit creation, e.g. --amend --fixup revert push after commit
  • For example, a single gitb c p replaces 4 commands:
git status git add ... git commit -m "type(scope): ..." git push
  • Print a list of unpushed commits, push them to the current remote branch or pull changes first
  • Avoid calling git push ... -> git pull ... -> git push ... if there are unpulled changes in branch, gitb push handles such changes in a single call
  • Fetch current branch and then ff/merge/rebase changes with conflicts fixing
  • You can choose merge or rebase mode if fast-forward is not possible
  • For example, you can avoid starting a merge due to an accidental call of git pull origin main while being in another branch
  • With gitb b you can select a branch to switch from a list, it may be helpful if you don't remember the name of the branch
  • With gitb b nd you can create a new branch from the default one with latest changes. It replaces these commands:
git switch main git pull origin main git switch -c ...
  • With gitb t you can create a new tag from a current commit and push it to a remote
  • Full tag managment: creation, fetching, pushing, deleting, checkout
  • Select branch to merge into the current one and fix conflicts
  • Create a merge commit after merging
  • Rebase branch with pretty conflict fixing without infinite writing of git rebase --continue
  • Select a commit to rebase with autosquash, it is very helpful to make a commit history better
  • Undo commits and actions in the fast way
  • Interactive stash management with multiple options: select files, stash all, list, pop, show, apply, and drop
  • Smart file selection with pattern matching and wildcard support
  • Easy navigation through existing stashes with formatted display

gitbasher supports AI-powered commit message generation using Google's Gemini API. The AI analyzes your staged changes and generates conventional commit messages automatically.

  • Visit Google AI Studio
  • Create a new API key
  • Copy the API key for configuration

Enter your Gemini API key when prompted. You can set it locally (for current repo) or globally (for all repos).

3. Configure Proxy (Optional)

If you're in a region where Gemini API is restricted, configure an HTTP proxy:

Examples:

CommandAliasesDescription
gitb c ai i llm Generate AI commit message for staged files
gitb c aif if llmf Fast AI commit (add all files + AI message)
gitb c aip ip llmp AI commit with automatic push
gitb c aifp ifp llmfp Fast AI commit with push
gitb c ais is llms AI commit with manual type/scope selection
gitb c aim im llmm AI commit with multiline message
  • Smart analysis: AI examines file changes, diff content, and commit patterns
  • Conventional commits: Generates proper type(scope): subject format
  • Geographic bypass: Proxy support for regions with API restrictions
  • Multi-modal: Short and long commit message generation
  • Error handling: Helpful error messages and solution suggestions
Command Short aliases Description
commit c co com Everything about commit creation
push p ps ph Pushing changes to a remote repository
pull pu pl pul Pulling changes from a remote repository
branch b br bran Managing branches
tag t tg Managing tags
merge m me Merge changes to the current branch
rebase r re base Rebase current branch
reset res Easy to use git reset
stash s sta Manage git stashes
config cf cfg conf Configurate gitbasher
status st Info about repo and changed files
log l lg Open git log in a pretty format
reflog rl rlg Open git reflog in a pretty format
help h man Show help

ModeShortDescription
<empty> Select files to commit and create a conventional message in format: type(scope): message
msg m Same as <empty>, but create multiline commit message using text editor
ticket t Same as <empty>, but add tracker's ticket info to the end of the commit header
fast f Add all files (git add .) and create a conventional commit message without scope
fasts fs Add all files (git add .) and create a conventional commit message with scope
push pu p Create a conventional commit and push changes at the end
fastp fp Create a conventional commit in the fast mode and push changes
fastsp fsp fps Create a conventional commit in the fast mode with scope and push changes
ai llm i Generate AI commit message based on staged changes
aif llmf if Fast AI commit (add all files + AI message) without confirmation
aip llmp ip Generate AI commit message and push changes
aifp llmfp ifp Fast AI commit with push (add all + AI message + push)
ais llms is Generate AI commit summary with manual type and scope selection
aim llmm im Generate AI commit message with multiline format
fixup fix x Select files and commit to make a --fixup commit (git commit --fixup <hash>)
fixupp fixp xp Select files and commit to make a --fixup commit and push changes
fastfix fx Add all files (git add .) and commit to make a --fixup commit
fastfixp fxp Add all files (git add .) and commit to make a --fixup commit and push changes
amend am a Select files and add them to the last commit without message edit (git commit --amend --no-edit)
amendf amf af Add all fiels to the last commit without message edit (git commit --amend --no-edit)
last l Change commit message to the last one
revert rev Select a commit to revert (git revert -no-edit <commit>)
help h Show this help

ModeShortDescription
<empty> Print list of commits, push them to current branch or pull changes first
yes y Same as <empty> but without pressing 'y'
force f Same as <empty> but with --force
list log l Print a list of unpushed local commits without actual pushing it
help h Show this help

ModeShortDescription
<empty> Fetch current branch, try to fast-forward or ask about strategy
fetch fe Fetch current branch without merge
all fa Fetch all without merge
upd u Run git remote update to fetch all branches
ffonly ff Fetch and then merge in fast forward only mode
merge m Fetch current branch and then merge it
rebase r Fetch current branch and then rebase
interactive ri rs Fetch current branch and then rebase in interactive mode with --autosquash
help h Show this help

ModeShortDescription
<empty> Select a local branch to switch
list l Print a list of local branches
remote re r Fetch origin and select a remote branch to switch
main def m Switch to main without additional confirmations
new n c Build a conventional name and create a new branch from main
newd nd Build a conventional name, switch to main, pull it and create new branch
delete del d Select a local branch to delete
help h Show this help

ModeShortDescription
<empty> Create a new tag from the last commit
annotated a an Create a new annotated tag from the last commit
commit c co cm Create a new tag from a selected commit
all al Create a new annotated tag from a selected commit
push ps ph p Select a local tag and push it to the remote repository
push-all pa Push all tags to the remote repository
delete del d Select a tag to delete
delete-all da Delete all local tags
list log l Print a list of local tags
remote fetch r Fetch tags from the remote repository and print it
help h Show this help

ModeShortDescription
<empty> Select a branch to merge into the current one and fix conflicts
main m Merge main to the current branch and fix conflicts
to-main tm Switch to main and merge the current branch into main
help h Show this help

ModeShortDescription
<empty> Select base branch to rebase current changes
main m Rebase current branch onto default branch
interactive i Select base commit in current branch and rebase in an interactive mode
autosquash a s f ia Rebase on the current local branch in an interactive mode with --autosquash
help h Show this help

ModeShortDescription
<empty> Reset last commit (git reset HEAD^ --mixed)
soft s Reset last commit, but remain all fiels staged (git reset HEAD^ --soft)
undo u Undo last commit reset (git reset HEAD@{1})
interactive i Select a commit to reset
ref r Select a HEAD reference to reset
help h Show this help

ModeShortDescription
<empty> Show interactive menu with all stash operations
select sel Select specific files to stash
all Stash all changes including untracked files
list l List all existing stashes
pop p Pop (apply and remove) from selected stash
show s Show contents of selected stash
apply a Apply selected stash without removing it
drop d Drop (delete) selected stash
help h Show this help

ModeShortDescription
<empty> Print current gitbasher configuration
user u name email Set user name and email
default def d b main Update gitbasher's default branch (not in remote git repo!)
separator sep s Update separator between type and name in branch
editor ed e Update text editor for the commit messages
ticket ti t jira Set ticket prefix to help with commit/branch building
scopes sc s Set a list of scopes to help with commit building
ai llm key Set AI API key for commit message generation
proxy prx p Set HTTP proxy for AI requests (bypass geo-restrictions)
delete unset del Unset global configuration

Most likely, if you have Linux, the necessary software is already installed on your machine. On MacOS, there is an outdated bash and there may be no git by default, so you should use homebrew to install it. On Windows you should use wsl, it will create a Linux environment for you with all necessary software.

  • bash version from 4.0
    • Debian-based: apt install --only-upgrade bash
    • MacOS: brew install bash
  • git version from 2.23
    • Debian-based: git --version || apt install git
    • MacOS: git --version || brew install git
sudo rm /usr/local/bin/gitb

If you'd like to contribute to gitbasher, make a fork and submit a pull request. You also can open an issue or text me on Telegram: https://t.me/maxbolgarin

Here are the possible values for <scope> in a commit message header. Use only these values when making commits in this repository (use no scope for global changes):

ScopeDescription
commit Changes mainly in commit.sh script, related to commit features and fixes
push Changes mainly in push.sh script, related to push features and fixes
pull Changes mainly in pull.sh script, related to pull features and fixes
merge Changes mainly in merge.sh script, related to merge features and fixes
rebase Changes mainly in rebase.sh script, related to rebase features and fixes
branch Changes mainly in branch.sh script, related to branching features and fixes
tag Changes mainly in tag.sh script, related to tag features and fixes
reset Changes mainly in reset.sh script, related to reset features and fixes
stash Changes mainly in stash.sh script, related to stash features and fixes
config Changes mainly in config.sh script, related to config features and fixes
ai Changes mainly in ai.sh script, related to AI features and fixes

The source code license is MIT, as described in the LICENSE file.

Read Entire Article