How do you create an alias for a Git command?

How do you create an alias for a Git command?

a) git config --global alias.alias-name 'git-command'
b) git alias create alias-name
c) git alias git-command alias-name
d) git create alias alias-name

Answer:

a) git config --global alias.alias-name 'git-command'

Explanation:

The git config --global alias.alias-name 'git-command' command creates an alias for a Git command, allowing you to use a shorter or custom command instead of the full command.

For example, you can create an alias for git status by running git config --global alias.st 'status', and then use git st instead of typing git status.

Using aliases can make frequent or complex commands easier to remember and faster to execute.

Reference:

Top 100 Git and GitHub MCQ Questions and Answers

Scroll to Top