Git Alias Multiple Commands

You can use the git alias to combine multiple git commands into a single shortcut. As shown below.

[alias]
   last-commit = !sh -c 'git log -1 && echo && git diff --stat HEAD'

If you execute the last-commit it will include the following.

“git log -1” will give the details of the last commit that you have committed. Echo is used for the separation of lines, and git diff –stat HEAD displays the changes made in the last commit.“!sh -c” allows you to execute the sequence of git commands to be executed. 

Aliases in Git

Pre-requisite: Git

Aliases are the user-friendly names given by a user to a git command so that the user doesn’t need to memorize the whole lengthy syntax of a git command. Let us go through some key terminologies

!: Somewhere in the ~/.gitconfig file, you will see this symbol. This is used to allow full shell syntax in git commands.

Similar Reads

How Do I Create Git Aliases?

There are two ways of creating aliases in git with the ~/.gitconfig file. So as we can see that the ~/.gitconfig file is opened and we can open it using any default text editor present in our git bash....

6 Useful Git Aliases

Below are the most used aliases...

Git Alias Multiple Commands

You can use the git alias to combine multiple git commands into a single shortcut. As shown below....

Autocorrect Your Aliases

By using help.autocorrect configuration option you can enable auto-correct for git commands. If you type any mistake in the command git will automatically suggest the correct one....

Frequently Asked Questions

1. What is a git alias?...

Contact Us