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.
Contact Us