Blog

Type Less When Using Git on the Command Line with Gitsh

Placeholder Avatar
Arunan Skanthan
September 9, 2020

For users who like using the command line version of Git like myself, it can get very repetitive to type git before each git command. e.g. git log, git add ., etc.

While adding aliases to your Git configuration can reduce the typing, you still have to prefix each command with with git . e.g. You can alias checkout to co and type git co instead of git checkout.

Also, you usually need to type more than one git command in sequence.

This is where gitsh, an interactive shell for Git, can help you.

Once installed, you type gitsh in the command line to start an session1. Now you are able to run Git commands without prefixing them with git . e.g. log will show you the equivalent of git log.

You can even use Git aliases. e.g. co develop instead of checkout develop.

As a bonus, just pressing the Return key will show you the result of git status. Even less typing needed!

If you need to execute a shell command within gitsh, you can prefix it with a !. e.g. !pwd.

The gitsh prompt also shows the current state of your repository, which includes the name of the current branch and a status indicator, in colour.

To exit you type :exit or press Ctrl + d.

You can see full details in the README.

1. You may want to dedicate a terminal tab or window to run gitsh if you use Git frequently.