乐闻世界logo
搜索文章和话题

How to List All Aliases Set in Git?

2024年7月4日 00:38

In Git, aliases help simplify commands, making complex command sequences easier to remember and execute. To list all aliases set in Git, you can use Git's configuration system. The specific command is:

bash
git config --get-regexp alias

This command retrieves the Git configuration file (typically .gitconfig or in the repository's .git/config file), searches for all configuration items starting with "alias", and displays them. Each alias is listed in the format alias.<name> <command>, where <name> is the alias name and <command> is the corresponding Git command.

For example, if you previously configured the following aliases:

  • Configure git cm to git commit -m
  • Configure git st to git status
  • Configure git lg to git log --graph --oneline

After executing git config --get-regexp alias, the output will resemble:

shell
alias.cm commit -m alias.st status alias.lg log --graph --oneline

This allows you to quickly view all configured aliases and their corresponding Git commands.

标签:Git