How to install Git "go" in Ubuntu 16.04

Source: Internet
Author: User
Tags how to use git version control system git clone

Transferred from: https://www.howtoing.com/how-to-install-git-on-ubuntu-16-04/

Introduced

The indispensable tool in modern software development is some kind of version control system. The version control system allows you to track your software at the source level. You can track changes, revert to the previous phase, and branch to create alternate versions of files and directories.

One of the most popular version control systems is the git Distributed version control system. Many projects keep their files in a git repository, and sites like GitHub and BitBucket make it easy and valuable to share and contribute to your code.

In this guide, we will demonstrate how to install and configure git an Ubuntu 16.04 system. We'll show you how to install the software in two different ways, each of which is beneficial.

This tutorial assumes that you are signing up for a non-root user and you can learn how to build it here.

How to install git with apt

The easiest way to get git installed and ready to use is to use Ubuntu's default repository so far. This is the quickest method, but the version may be older than the latest version. If you need the latest version, please consider the following steps to compile git from source code.

You can use apt the package management tool to update your local package index. After that, you can download and install the program:

sudo apt-get updatesudo apt-get install git

This will download and install git for your system. You still have to complete the configuration steps described in our "Settings" section, and you can skip this section at will.

How to install Git from source code

The more flexible way to install git is the software compiled from the source code. This takes longer and will not be maintained by your package manager, but it will allow you to download the latest version and will give you some control over the options you include if you want to customize.

Before you start, you need to install the software git dependencies. This is available in the default repository, so we can update our local package index and then install the packages:

sudo apt-< Span class= "KWD" >get Updatesudo apt-get install build -essential libssl< Span class= "pun" >-dev libcurl4- gnutls--dev gettext unzip     

After you have installed the necessary dependencies, you can continue to get a mirror of the Git project on GitHub by accessing the GIT version you want.

The version you see when you arrive at the project page is a branch that is actively working on. If you want the latest stable version, you should use this button to the left of the item title to change the branch to the latest non-"RC" tag:

Next, on the right side of the page, right-click the download zip button to copy the link address.

Back on your Ubuntu 14.04 server, you can type and wget follow it by pasting the copied address. The URL you copied may be different from my URL:

wget https://github.com/git/git/archive/v2.8.1.zip -O git.zip

Unzip the file that you downloaded and move to the results directory by typing the following:

unzip git.zipcd git-*

You can now create a package and install it by typing the following two commands:

make prefix=/usr/local allsudo make prefix=/usr/local install

Now that you have git installed, if you want to upgrade to a later version, you can simply clone the library (make sure to change your home directory first), then build and install. To find the URL to use for the cloning operation, browse to the page of GitHub where you want to branch or tag the item, and then copy the right clone URL:

Change your home directory and use git clone the URL you just copied:

cd ~git clone https://github.com/git/git.git

This will create a new directory in the current directory where you can rebuild the package and reinstall the newer version as you did above. This will overwrite your old version with the new version:

cd gitmake prefix=/usr/local allsudo make prefix=/usr/local install
How to set up git

Now that you have git installed the few things you need to do, such a promise will generate a message that you will contain your correct information.

The simplest way to do this is through git config commands. Specifically, we need to embed this information for our name and email address git into every promise we make. We can add this information directly by entering the following:

git config  --global.name  " Your name "git config < Span class= "pun" >--global user .email  " [Email protected]  "             

[email protected]? item:

git config --list
Git configuration
user< Span class= "pun" >.name= Your name user.email=.com                

As you can see, this has a slightly different format. This information is stored in your git profile and you can select edit from a text editor such as the hand:

nano ~/.gitconfig
?/. Gitconfig Content
[< Span class= "PLN" >user] name =  your name  email =[email protected] com             

There are many other options that can be set, but these are necessary for both. If you skip this step, you may see a warning when you promise git something similar to this:

Output when git username and email is not set
[Master0d9d21d]Initial project versionCommitter:RootYourNameandEmail address were configured automatically basedon your usernameandHostname. PleaseCheck that they is accurate.YouCan suppressThisMessageBySetting them explicitly:git config--GlobalUser.Name"Your Name"git config--GlobalUser.Email[Email protected].Comafter doing this, You may fix the identity used < Span class= "KWD" >for this  commit with : git commit --amend ---author     

This does more work for you, because you will have to modify the submissions that you made to the corrected information.

Conclusion

You should now have the git installation and ready to use on your system. To learn more about how to use Git, see these articles:

How to install Git "go" in Ubuntu 16.04

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.