How to install and configure Git in Ubuntu system

  
                

Git is a free distributed version control system that can help Linux kernel development. The merge tracking capability is a highlight of Git. How do you install and configure Git in Ubuntu system? The following small series introduces you to the Ubuntu installation and configuration of Git, and a brief description of the use of Git.

a, Git installation:

1, the binary attached:

$ sudo apt-get install git-core

After the installation , enter git in the terminal to see the relevant commands. If you just need to use git to manage your local code, you can use it now. If you need to combine with the project on github, you need to do some other operations.

2, github account application

If you just need to copy the code of interest on github to the local, modify it for use, and do not intend to share the release, in fact, do not apply for an account Relationships, just git clone code to the local. $ git clone git://IP work (working directory name).

After all, using github is for open source purposes. First, register an account on github.com.

3, create a folder locally, and then do some global variable initialization

$ git config --global user.name = “username or user ID”

$ git config --global user.email = mailbox

These two options are automatically added to the code during future use.

4, create a public key for verification

This is a more complicated and troublesome place, because git access to the repository through ssh, so you need to create a local authentication Used files. Use the command: $ ssh-keygen -C ‘you email [email protected]’ -t rsa will create the corresponding key file in the user directory ~/.ssh/. You can use the $ ssh -v [email protected] command to test if the link is clear.

5, upload the public key

In the interface of github.com, select Account Settings in the upper right corner, then select SSH Public Keys and select the new one.

Title can be named casually. The contents of Key are copied from ~/.ssh/id_rsa.pub. After completion, you can use ssh -v [email protected] to test. See the message below to indicate that the verification was successful.

Second, Git configuration and use

Using github to manage your own projects, you can follow the steps below

1. Create a warehouse

In the folder where the project is created, use git init to build the repository. When you're done, you can see that there is one more .git hidden directory in the file home.

2, add files

Use git add . To add the initial file. Here . It means that all the files under the folder are added, we can also specify the file to add.

3, submit file

Use git commit -m ‘comment’ submit, you can submit the edited content.

4, delete or add github remote source

git remote add origin https://github.com/Git-Elite/CodeBase.git //blue part is the github-managed warehouse address

5, submit to github repository

git push -u origin master

The above is the Ubuntu installation and configuration Git method introduced, before using Git, you need to establish A github repository, then you can use git to manage Linux projects.

Copyright © Windows knowledge All Rights Reserved