git config alias

Source: Internet
Author: User
Tags commit

There are often wrong orders. Like git status. Status The word is really hard to remember.

If you tap git st to show git status that's a lot easier, of course this lazy way we are strongly in favor of.

We just need to hit a line and tell git that the status will be:

$ git config--global alias.st status

OK, now knock git St to see the effect.

Of course, there are other orders can be abbreviated, many people use Co to express Checkout,ci COMMIT,BR represents branch:

$ git config--global alias.co checkout
$ git config--global alias.ci commit
$ git config--global alias.br branc H

Subsequent submissions can be simply written as follows:

$ git ci-m "Bala Bala Bala ..."

The--global parameter is a global parameter, which is useful for all git repositories on this computer.

In the Undo changes section, we know that the command git reset HEAD file can undo the staging area modification (unstage) and re-put it back in the workspace. Since it is a unstage operation, you can configure a unstage alias:

$ git config--global alias.unstage ' reset HEAD '

When you typed the command:

$ git unstage test.py

In fact, Git does this:

$ git reset HEAD test.py

Configure a git last to display the final commit information:

$ git config--global alias.last ' log-1 '

This way, the last commit can be shown with git:

$ git last
commit adca45d317e6d8a4b23f9811c3d7b7f0f180bfe2
merge:bd6ae48 291bea8
author:michael Liao <askxuefeng@gmail.com>
Date:   Thu 22:49:22 +0800

    merge & Fix hello.py

There are even people who have been desperate to configure LG as:

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 '

Look at the effects of git LG:

Why didn't you tell me earlier? Don't be excited, we're not trying to memorize a few English words. configuration file

When configuring Git, plus--global is working for the current user, if not, it only works for the current warehouse.

Where did the configuration file go? The GIT configuration files for each repository are placed in the. git/config file:

$ cat. Git/config 
[core]
    repositoryformatversion = 0
    FileMode = true
    bare = False
    logallrefupdates = True
    ignorecase = True
    Precomposeunicode = True
[remote "origin"]
    URL = git@github.com:michaelliao/ Learngit.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    Remote = origin
    Merge = Refs/heads/master
[alias] Last
    = log-1

Alias is immediately after [alias], to delete the alias, the corresponding line can be deleted.

The current user's git configuration file is placed in a hidden file in the user's home directory. Gitconfig:

$ cat. Gitconfig
[alias]
    CO = checkout
    CI = commit
    br = Branch
    st = Status
[user]
    name = Your Name
    email = your@email.com

Configuration aliases can also directly modify the file, if the wrong, you can delete the file re-configuration through the command.

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.