4.2.4. Git Aliases

By using Git aliases you can run Git command, or a set of Git commands using an alternate, and generally short command.

4.2.4.1. Git Status

For example, let’s see the Git command, git status.

A typical output of git status looks like below:

$ git status

On branch main

Your branch is up to date with 'origin/main'.


Changes not staged for commit:

  (use "git add <file>..." to update what will be committed)

  (use "git restore <file>..." to discard changes in working
  directory)

    modified: cm/git/index.rst


Untracked files:

  (use "git add <file>..." to include in what will be committed)

    cm/git/git-aliases.rst

    cm/git/git-common-local-operations.rst

    cm/git/git-common-online-operations.rst

    cm/git/git-further-reading.rst


no changes added to commit (use "git add" and/or "git commit -a")

If you want to get a shorter brief status, you can use the argument –short:

$ git status --short

 M cm/git/index.rst

?? cm/git/git-aliases.rst

?? cm/git/git-common-local-operations.rst

?? cm/git/git-common-online-operations.rst

?? cm/git/git-further-reading.rst

If you add the following lines to your ~/.gitconfig:

[alias]

    st = status --short

you can now run a command, git st, and the output would be:

$ git st

 M cm/git/index.rst

?? cm/git/git-aliases.rst

?? cm/git/git-common-local-operations.rst

?? cm/git/git-common-online-operations.rst

?? cm/git/git-further-reading.rst