The installation and simple configuration of Git under Mac

Source: Internet
Author: User
Tags aliases

git local operationsabout Git1, git is distributed SCM,SVN is centralized2, git each historical version of the complete file storage, SVN store file differences3, Git can do most of the operation offline, SVN is the opposite4. Git has a more elegant branching and merging implementation5, Git has a stronger ability to undo the revision and revision history6, Git faster, more efficient
One, download git address under Machttp://git-scm.com

http://sourceforge.net/projects/git-osx-installer/


1. Switch to the latest version, your favorite versioninput: which-a git2. Show which version of Git we are usinggit--version3. Make sure the installation is the version you just downloadedvim. Bash_profileInput: Export path=/usr/local/git/bin: $PATH
load source. Bash_profielagain, look at the success of the changes you just made:

hairongchen:~ $git-version

Display: Git version 2.2.1

Second, configure git input command to complete automatically

1. Enter Http://github.com/git/gitDownload the git package and unzip it to a location
2. Enter the newly unzipped position at the terminalEnter the contrib/completion/folder againfound four files and the following two files are what we need gIt-completion.bashgit-prompt.shCopy the above two files to the current user's home directory

CP Git-completion.bash ~/

CP git-prompt.sh ~/


Modified. Bash_profile

Vim. Bash_profile

Enter the following content

# copy Contrib/copmletion/git-completion.bash to your home directory and source it

# Linux users should add the line below to your. BASHRC

. ~/git-completion.bash


#copy contrib/completion/git-prompt.sh to your home directory and source it

#Linux users should add the line below to your. BASHRC

. ~/git-prompt.sh

Export git_ps1_showdirtystate=1

# Export ps1= ' \w$ (__git_ps1 "(%s)") \$ '

Export ps1= ' \u:\w$ (__git_ps1 "(%s)") \$ '

the above two files are mostly auto-completed and informative when git enters commandsto prevent an error in the input command
Save exit and source a bit. Bash_profile

3. When we enter Git confi and press the TAB key, it will be automatically filledenter git config--some parameters are listed
Three, git simple configuration1>.git The most basic configurationInstall and configure the git input command to finish automatically, and you need the last step to use thegit config-global user.name**** * * Set to your own user namegit config-global user.email * * ** * * Enter your own e-mail
three levels of 2>git configurationgit config-systemgit config-globalgit config-localLocal to the current warehouse, from a priority, the local highest, followed by global, because he is the current user, and finally the system
three ways to check git config document

Git config-help

git help config

Mans Git-config


3>git configuration additions and deletions1. Add user name above, email one, a key followed by a value
2. Git config-global-add user.name rhcadd indicates that he has more than one of these key-value pairsYou can query this value based on this key git config user.nameyou can also use git config-get user.name to querythrough the above two command query, the user name is add in the RHC
3. With Git Config-list-global, you can see the key values and find two User.NameIt's just the last rhc.

hairongchen:git-master$ git config--list--global

User.name=chenhairong

[Email protected]

User.name=rhc


4. Delete

hairongchen:git-master$ git config--global--unset user.name

A warning appears:

Warning:user.name has multiple values

We need user.name followed by an expression such as:git config--global--unset user.name rhc

re-check:

hairongchen:git-master$ git config--list--global

User.name=chenhairong

[Email protected]

User.Name found that there is only one value, only one value is deleted without adding expressions such as:

git config--global--unset user.name

Check again: git config--get user.name, I can't find it.

We'll add back:

git config--global user.name rhc


5. Modification:

git config--global user.email [email protected], changed the previous email:

hairongchen:git-master$ git config--list--global

[Email protected]

User.name=rhc



4> Configuring aliases for Git subcommandsalias for Checkout co:git config--global alias.co checkout The branch,status,commit configuration aliases are as follows:

git config--global alias.br branch

git config--global alias.st status

git config--global alias.ci commit


Enter Git c and then press TAB to appear, more co,ci two commands, we can later use CI to Commit,co to checkout

hairongchen:git-master$ git C

C Cherry Citool cm commit

CA cherry-pick Clean Co config

Checkout CI clone column


Git back-up parameters

Input command discovery: Git log discovery output a lot of content later

Use the following command:git config--global alias.lol "Log-oneline"

And then use git lol to find a line that's neat

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

The installation and simple configuration of Git under Mac

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.