Git command custom alias

Source: Internet
Author: User
Tags git commands

Aliases are used to help you define your own git commands. For example, you can definegit aTo rungit add --all.

To add an alias, open~/.gitconfigFile and add the following content:

[alias]  co = checkout  cm = commit  p = push  # Show verbose output about tags, branches or remotes  tags = tag -l  branches = branch -a  remotes = remote -v

... Or type:

$ git config --global alias.new_alias git_function

For example:

$ git config --global alias.cm commit

Aliases pointing to multiple commands can be defined using quotation marks:

$ git config --global alias.ac ‘add -A . && commit‘

Some useful aliases are listed below:

Alias alias Command How to Set what to type
git cm git commit git config --global alias.cm commit
git co git checkout git config --global alias.co checkout
git ac git add . -A git commit git config --global alias.ac ‘!git add -A && git commit‘
git st git status -sb git config --global alias.st ‘status -sb‘
git tags git tag -l git config --global alias.tags ‘tag -l‘
git branches git branch -a git config --global alias.branches ‘branch -a‘
git remotes git remote -v git config --global alias.remotes ‘remote -v‘
git lg git log --color --graph --pretty=format:‘%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset‘ --abbrev-commit -- git config --global alias.lg "log --color --graph --pretty=format:‘%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset‘ --abbrev-commit --"


Source: tonyxue

Git command custom alias

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.