Using Git in Mac OS

Source: Internet
Author: User
Tags how to use git using git

Objective:

Most of the time since work has been the use of SVN, git do not know much, now because of the need for work, here is recorded under the Mac system how to use Git.

PS: Legend has it that Git was the founder of the Linux system, Linus spent 2 weeks in C language to develop, worship here.

Steps to use:

1, Installation and configuration

There are many installation methods on the network, you can search your own favorite way. Let's talk about my installation process.

In Mac, Xcode integrates with Git, just start Xcode, open menu xcode -and open Developer Tool , more Developer Tools , the system will automatically open the Apple Developer website, log in, find command line Tools (OS X 10.11) for Xcode xxx, download down and install, XXX is the corresponding Xcode version number.

Configure SSH (enter the command in the terminal)

Step1, by opening.SSH directory to check if SSH has been configuredCD~/.SSH//Step2, if you have not configured SSH, you should have the following prompt. If there is an. ssh directory stating that SSH has been configured, you can skip Step3-bash:CD:. ssh:no such file or director

Step3, configure SSH, create an SSH key
Ssh-keygen-t rsa-c "[Email protected]"
/*
Parameter description
-T: Specifies the secret key type, which is RSA by default. This item can be omitted
-C: (Note that C is uppercase), set the comment text, such as the mailbox, recommended to use the mailbox registered with GitHub or registered Gitlab.
-F: The above omits the-F, which is used to specify a file to hold SSH key. If not specified, use the default file name (recommended) and generate two key files, Id_rsa and id_rsa.pub
Note: The ID_RSA is the private key and cannot be leaked. Id_rsa.pub is a public key that can be compromised.


Then you will be prompted to enter the password (this password is the password required to push the file later, you can not enter the password directly, so push without entering the password),
Enter passphrase (empty for no passphrase):
Enter same Passphrase again:

If all goes well, you'll see a hint like this next
Your identification has been saved In/c/users/you/.ssh/id_rsa
Your Public Key has been saved In/users/your_pc_name/.ssh/id_rsa.pub
The key fingerprint is:
*/

Step4, after completing the above work, use the Pbcopy command (with the corresponding pbpaste command) to copy the contents of the Id_rsa.pub to the Clipboard
Using Pbcopy to copy the contents of the file to avoid copying errors, previously using CRTL + C and CRTL + V has been reported secret key errors.
Pbcopy < ~/.ssh/id_rsa.pub

>> If you're using GitHub, you'll need the following configuration to log on to GitHub.

And then

Then

Finally, the following:

>> If you are using Gitlab, configure the following

The next configuration,

After completing the above work, test configuration is ok,terminal enter the following command, if the display of successful authentication, the configuration is successful, otherwise please check where the error.

2, create a version library

Since the project does not start from scratch, it is not yet well-done and supplemented.

3, Cloning engineering

Configure your personal information before cloning to let the server know who you are.

git config--global user.name "Your name"git config--global user. Email "[Email protected]"// this profile in the current user's main account Record, view file contents more ~/.gitconfig

Because it is halfway through the project, so the project has been developed part and saved on Gitlab (remote warehouse), the path of the project in the remote warehouse is roughly like this ssh://[email protected] (or IP addr): 10022/xxx/ Xxx.git, or the https://localhost:8082 (or IP addr)/xxx/xxx.git, I just need to clone a copy to be saved locally. Enter the following command in the terminal

clone the specified project from the remote repository to the current directory, git clone ssh:

The next step is the basic git operation, you can refer to the following links, written in very detailed.

Http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/ 0013743256916071d599b3aed534aaab22a0db6c4e07fd0000

  

Using Git in Mac OS

Related Article

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.