DEV Community

Cover image for Git faster with mingit

Git faster with mingit

sendra profile image Evan Sendra ・2 min read

I wrote mingit because I thought of how much we use git on the command line as day-to-day programmers and how much time we waste typing the same commands again and again. I thought why are we always typing

git commit -m "my super dope commit"
Enter fullscreen mode Exit fullscreen mode

when a simple

g c "my super dope commit"
Enter fullscreen mode Exit fullscreen mode

would suffice? And why git when by the time I write g my terminal knows what I'm going for?

So I wrote mingit. It's a small bit of shell code that can be installed with npm - npm install -g mingit.

Here's the short of it:

g a .                   // git add .
g b other-branch        // git branch other-branch
g c "made some changes" // git commit -m "made some changes"
g commit --amend        // it also works with regular subcommands
g co master             // git checkout master
g co mas<TAB><TAB>      // auto-complete still works! 🙌
g d                     // git diff
g f                     // git fetch
g i                     // git init 
g m hotfix              // git merge hotfix
g pll                   // git pull
g psh                   // git push
g s                     // git status
Enter fullscreen mode Exit fullscreen mode

See more here!

There were other git aliases out there already, but I wanted a git alias that:

  1. aliased the git command itself
  2. allowed aliasing of subsequent commands
  3. Didn't destroy tab completion (e.g. typing git checkout with the alias still provides things you can checkout)

The official git alias didn't accomplish #1, but it accomplishes #2 and #3.

Any other aliases I found accomplished #2 but not #3 and potentially not #1 (both deal breakers).

If you want to help make this tool better, I'd love to see your pull request!

Discussion (9)

Editor guide
calops profile image
Rémi Labeyrie

The official git alias didn’t accomplish #1, but it accomplishes #2 and #3.

I'm confused. Instead of just setting up a simple alias "g=git" in your shell and then using proper git aliases in your ~/.gitconfig, you decided that the better option was to just write a full-blown shell function that does it all? Why?

Also, I understand that NPM or whatever else make distribution and installation easier in theory, but we're talking about very basic configuration files here, it seems a bit overkill. No git user should have trouble with it.

sendra profile image
Evan Sendra Author

The g=git alias was my first idea, but tab completion stops working with a regular alias.

csomh profile image
Hunor Csomortáni

You can fix this with .git-completion.bash, by having something like this in your .bashrc:

alias g='git'

source $HOME/.git-completion.bash
__git_complete g _git
Enter fullscreen mode Exit fullscreen mode

More on this here.

danielescoz profile image
Daniel Escoz

With zsh completion works perfectly with aliases. Try it.

zakius profile image

idea is noble, but using node.js or py for everything... I'm getting tired of this, though I understand it's easiest way of making things multiplatform

developius profile image
Finnian Anderson

I think it's more about the ease of publishing, versioning and installing code. It would be easier to write a shell script with the aliases within and install that in the path, but it would be a pain to install & update. NPM takes care of all of that so we can get back to writing code 👍

eko24ive profile image
wmhilton profile image
William Hilton

Very clever!

chakzefir profile image

How about using .ohmyzsh git aliases, that coming on board with it?