How to install git on ubuntu
How to install git on ubuntu
How To Install Git on Ubuntu 20.04
Introduction
Version control systems like Git are essential to modern software development best practices. Versioning allows you to keep track of your software at the source level. You can track changes, revert to previous stages, and branch to create alternate versions of files and directories.
Many software projects’ files are maintained in Git repositories, and platforms like GitHub, GitLab, and Bitbucket help to facilitate software development project sharing and collaboration.
In this guide, we will go through how to install and configure Git on an Ubuntu 20.04 server. We will cover how to install the software two different ways: via the built-in package manager, and via source. Each of these approaches come with their own benefits depending on your specific needs.
Prerequisites
You will need an Ubuntu 20.04 server with a non-root superuser account.
With your server and user set up, you are ready to begin.
Installing Git with Default Packages
The option of installing with default packages is best if you want to get up and running quickly with Git, if you prefer a widely-used stable version, or if you are not looking for the newest available functionalities. If you are looking for the most recent release, you should jump to the section on installing from source.
Git is likely already installed in your Ubuntu 20.04 server. You can confirm this is the case on your server with the following command:
If you receive output similar to the following, then Git is already installed.
If this is the case for you, then you can move onto setting up Git, or you can read the next section on how to install from source if you need a more up-to-date version.
However, if you did not get output of a Git version number, you can install it with the Ubuntu default package manager APT.
First, use the apt package management tools to update your local package index.
With the update complete, you can install Git:
You can confirm that you have installed Git correctly by running the following command and checking that you receive relevant output.
With Git successfully installed, you can now move on to the Setting Up Git section of this tutorial to complete your setup.
Installing Git from Source
If you’re looking for a more flexible method of installing Git, you may want to compile the software from source, which we will go over in this section. This takes longer and will not be maintained through your package manager, but it will allow you to download the latest release and will give you greater control over the options you include if you wish to make customizations.
Verify the version of Git currently installed on the server:
If Git is installed, you’ll receive output similar to the following:
Before you begin, you need to install the software that Git depends on. This is all available in the default repositories, so we can update our local package index and then install the relevant packages.
After you have installed the necessary dependencies, create a temporary directory and move into it. This is where we will download our Git tarball.
Unpack the compressed tarball file:
Next, move into the new Git directory:
Now, you can make the package and install it by typing these two commands:
Now, replace the shell process so that the version of Git we just installed will be used:
With this complete, you can be sure that your install was successful by checking the version.
With Git successfully installed, you can now complete your setup.
Setting Up Git
After you are satisfied with your Git version, you should configure Git so that the generated commit messages you make will contain your correct information and support you as you build your software project.
Configuration can be achieved by using the git config command. Specifically, we need to provide our name and email address because Git embeds this information into each commit we do. We can go ahead and add this information by typing:
We can display all of the configuration items that have been set by typing:
The information you enter is stored in your Git configuration file, which you can optionally edit by hand with a text editor of your choice like this (we’ll use nano):
There are many other options that you can set, but these are the two essential ones needed. If you skip this step, you’ll likely see warnings when you commit to Git. This makes more work for you because you will then have to revise the commits you have done with the corrected information.
Conclusion
You should now have Git installed and ready to use on your system.
To learn more about how to use Git, check out these articles and series:
Want to learn more? Join the DigitalOcean Community!
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in our Questions & Answers section, find tutorials and tools that will help you grow as a developer and scale your project or business, and subscribe to topics of interest.
How to Install, Configure and Use GIT on Ubuntu?
In the previous article we learnt about what is Git all about.Now we’ll learn a more about git and its repository in more detail
Git is a distributed revision control system with an emphasis on speed, data integrity, and support for distributed, non-linear workflows. Every Git working directory is a full-fledged repository with complete history and full version-tracking capabilities, independent of network access or a central server.
GitHub is a Web-based Git repository hosting service, which offers all of the distributed revision control. Unlike Git, which is strictly a command-line tool, GitHub provides a Web-based graphical interface. GitHub is used for ‘version control’. This means that GitHub is used for software development projects when more than a person(or a group) is working on it. What GitHub does is that it creates a cloud-based centralized repository for everyone working in the group and allows everyone working on the project to update the information. One can also use BitBucket, if not GitHub.
INSTALLING GIT:
Step 1: Open the Terminal and type sudo apt-get install git
Step 2: Goto www.github.com and sign into your account. If you’re a new user, you can simply sign-up. (You can also use www.bitbucket.org as an alternative,but we will use github here).
You’ll have a username from here. Let us say that it’s your_username
CONFIGURING GIT:
Step 1: Go back to the terminal and type this to configure git
git config –global user.name “your_username”
Step 2: Now type this to link your email too.
git config –global user.email “your_emailid”
USING GIT:
Step 1: Go to your github account and create a repository with a name(lets say name of your project). We are creating a repository with the name myproject
Step 2: Make a folder with the name of your project and change your current directory to that directory.
Step 3: Now we want to initiate Git for this folder
Step 4: Now we will set up the remote, which tells git where the repository is located.
We have now configured and installed git and, created and configured a repository. Lets say we have a simple file in the myproject folder helloworld.c and we want it to share it with a friend who is working on the same project.
Step 5: To add this file we will type
git add helloworld.c
Or if we have a lot of files to be transferred from the folder to our git account, then we can use the command.
This would transfer the file(s) in the list which we will later commit.
Step 6: Next, when we are finished adding the files, then we will have to commit adding.
Step 7: Next, we need to push the commit that we just made on to the repository at github
git push origin master
It would automatically ask you for your username and password for github. After entering the details, go to github and refresh. The files would get added there.
Username for ‘ https://github.com ‘: your_username
Password for ‘ https://your_username@github.com ‘ : *******
Step 9: When we would go to our github account, we would see the entire hierarchy of the modification of the file. Here,we would see the changes we made to the helloworld.c file in the respective commits.
Step 10: First he would have to download the whole repository in which the file helloworld.c is present into his system.
A folder named myproject gets downloaded with all the files in it. The necessary changes are made and then the file is similarly added, committed and pushed similarly as above.
Step 11: If the first user wish to see the changes, then he can see it by typing:
git pull origin master
Article By Harshit Gupta:
Kolkata based Harshit Gupta is an active blogger having keen interest in writing about current affairs, technical Blogs, stories, and personal life experiences. Besides passionate about writing, he also loves coding and dancing. Currently studying at IIEST, he is an active blog contributor at geeksforgeeks. You can reach him at https://in.linkedin.com/pub/harshit-gupta/102/b71/605
If you also wish to showcase your blog here,please see GBlog for guest blog writing on GeeksforGeeks.
How To Install Git on Ubuntu 18.04 / 20.04
Home » SysAdmin » How To Install Git on Ubuntu 18.04 / 20.04
Git is a version control system used in modern software development. It allows multiple developers to work on the same project while tracking changes, revisions, and contributors.
This step-by-step guide walks you through installing and configuring Git on Ubuntu 18.04 or Ubuntu 20.04.
Install Git with Apt on Ubuntu
Using the apt package management tool is the easiest way to install Git. However, the version in the default repositories may not be the latest release from the developer. If you want to install the latest release, skip down to install from source.
1. To update the packages, launch a terminal window, and enter:
This helps to ensure you’re working with the latest software versions.
2. To install from the default repositories, enter the following:
Allow the process to complete.
3. Verify the installation and version by entering:
The output should appear as seen below:
Install Git From Source Code
To use the latest version of Git on Ubuntu, download and install from the original source code.
1. Start by installing the following packages:
Allow the process to complete.
2. Open a browser window and navigate to the following address:
3. You can select the version of Git you download by changing the branch to a specific version. Select the Master Branch.
Also, at the top, you see a link labeled releases to browse the different release versions. It is recommended that you avoid versions labeled with “rc.” This stands for release candidate, and may not be completely stable.
4. Click the green Clone or download button on the right-hand side. Copy the URL by clicking on the file icon.
5. Switch back to your command prompt and enter the following:
6. You are now working in the temp directory. Type in the following command:
This downloads the Git file, and renames it git.zip.
Note: If you found a package under the releases page, you can substitute the link to that version. For example:
7. Next, extract the zip files by entering the command:
8. Allow the process to finish. Then, move to the new directory:
9. Then, compile the package with the following command:
10. And once the process is finished, install the software with:
11. Verify Git installation by entering:
The output should appear as:
Configuring Git
Git contains a basic configuration file that holds your information. Setting your username and email address is essential.
1. In a terminal window, enter the following and replace your_name with your name, and [email protected] with your email address.:
2. Verify configuration changes with the command:
The system should display the name and email address you just entered.
Note: If you do not make these edits, you will receive a warning when you commit to Git which makes you go back and revise your commits.
Basic Git Commands
This is a list of useful Git commands to help you get started:
Now you know how to install Git on your Ubuntu system. You also learned configuration and basic Git commands, which will help you manage your projects more effectively.
For CentOS, Windows, or macOS systems, see our guide on installing Git on CentOS 7, installing git on Windows, and installing Git on MacOS. Also, don’t forget to download our Git Commands Cheat Sheet for free to have the most commonly used commands always at your hand.
How To Install Git on Ubuntu 18.04 [Quickstart]
Introduction
Version control systems help you share and collaborate on software development projects. Git is one of the most popular version control systems currently available.
This tutorial will walk you through installing and configuring Git on an Ubuntu 18.04 server. For a more detailed version of this tutorial, with better explanations of each step, please refer to How To Install Git on Ubuntu 18.04.
Step 1 — Update Default Packages
Logged into your Ubuntu 18.04 server as a sudo non-root user, first update your default packages.
Step 2 — Install Git
Step 3 — Confirm Successful Installation
You can confirm that you have installed Git correctly by running this command and receiving output similar to the following:
Step 4 — Set Up Git
Now that you have Git installed and to prevent warnings, you should configure it with your information.
If you need to edit this file, you can use a text editor such as nano:
Related Tutorials
Here are links to more detailed tutorials that are related to this guide:
Want to learn more? Join the DigitalOcean Community!
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in our Questions & Answers section, find tutorials and tools that will help you grow as a developer and scale your project or business, and subscribe to topics of interest.
How To Install Git on Ubuntu 18.04
Introduction
Version control systems are increasingly indispensable in modern software development as versioning allows you to keep track of your software at the source level. You can track changes, revert to previous stages, and branch to create alternate versions of files and directories.
One of the most popular version control systems currently available is Git. Many projects’ files are maintained in a Git repository, and sites like GitHub, GitLab, and Bitbucket help to facilitate software development, project sharing, and collaboration.
In this guide, you will install and configure Git on an Ubuntu 18.04 server. This guide will cover how to install the software two different ways: via the built-in package manager, and via source. Each of these approaches come with their own benefits depending on your specific needs.
Prerequisites
In order to complete this tutorial, you should have a non-root user with sudo privileges on an Ubuntu 18.04 server. To learn how to achieve this setup, follow our Initial Server Setup Guide.
With your server and user set up, you are ready to begin.
Installing Git with Default Packages
Ubuntu’s default repositories provide you with a fast method to install Git. Note that the version you install via these repositories may be older than the newest version currently available. If you need the latest release, consider moving to the next section of this tutorial to learn how to install and compile Git from source.
First, use the apt package management tools to update your local package index:
With the update complete, you can download and install Git:
You can confirm that you have installed Git correctly by running the following command:
With Git successfully installed, you can now move on to the Setting Up Git section of this tutorial to complete your setup.
Installing Git from Source
A more flexible method of installing Git is to compile the software from source. This takes longer and will not be maintained through your package manager, but it will allow you to download the latest release and will give you some control over the options you include if you wish to customize.
Verify the version of Git currently installed:
If Git is installed, you’ll receive output similar to the following:
Before you begin, you need to install the software that Git depends on. This is all available in the default repositories, so you can update your local package index:
Then install the packages:
After you have installed the necessary dependencies, move into the tmp directory. This is where you will download your Git tarball:
Unpack the compressed tarball file:
Next, move into the new Git directory:
Now, you can make the package and install it by typing these two commands:
Now, replace the shell process so that the version of Git you just installed will be used:
With this complete, you can be sure that your install was successful by checking the version:
With Git successfully installed, you can now complete your setup.
Setting Up Git
After you are satisfied with your Git version, you should configure Git so that the generated commit messages you make will contain your correct information and support you as you build your software project.
This can be achieved by using the git config command. Specifically, you need to provide your name and email address because Git embeds this information into each commit you do. Add this information by typing:
Display all of the configuration items that have been set by typing:
The information you enter is stored in your Git configuration file, which you can optionally edit by hand with your preferred text editor. The following example uses nano :
There are many other options that you can set, but these are the two essential ones needed. If you skip this step, you’ll likely see warnings when you commit to Git. This makes more work for you because you will then have to revise the commits you have done with the corrected information.
Conclusion
Git is a great way to keep track of changes, revert to previous stages, or branch to create different versions of files and directories. With this tutorial, you’ve learned how to install Git on your system and how to set up the essential Git configurations.
To learn more about how to use Git, check out these articles and series:
Want to learn more? Join the DigitalOcean Community!
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in our Questions & Answers section, find tutorials and tools that will help you grow as a developer and scale your project or business, and subscribe to topics of interest.
Still looking for an answer?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
@johnaaronrose — you can look at the official Git documentation for extra guidance. You can click the link for Justin’s tutorial to see the full post, but that is a server setup installation not a desktop. This tutorial also assumes the use of a server. Often, desktops will function the same but there may be differences.
git fails to install on 18.04 using sudo apt install git: john@JohnPC:
$ sudo apt install git [sudo] password for john: Reading package lists… Done Building dependency tree
Reading state information… Done The following additional packages will be installed: git-man liberror-perl Suggested packages: git-daemon-run | git-daemon-sysvinit git-doc git-el git-email git-gui gitk gitweb git-cvs git-mediawiki git-svn The following NEW packages will be installed git git-man liberror-perl 0 to upgrade, 3 to newly install, 0 to remove and 3 not to upgrade. 4 not fully installed or removed. Need to get 4,731 kB of archives. After this operation, 33.9 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://gb.archive.ubuntu.com/ubuntu bionic/main amd64 liberror-perl all 0.17025-1 [22.8 kB] Get:2 http://gb.archive.ubuntu.com/ubuntu bionic-updates/main amd64 git-man all 1:2.17.1-1ubuntu0.1 [803 kB] Get:3 http://gb.archive.ubuntu.com/ubuntu bionic-updates/main amd64 git amd64 1:2.17.1-1ubuntu0.1 [3,905 kB] Fetched 4,731 kB in 1s (6,041 kB/s) Selecting previously unselected package liberror-perl. (Reading database … 221319 files and directories currently installed.) Preparing to unpack …/liberror-perl_0.17025-1_all.deb … Unpacking liberror-perl (0.17025-1) … Selecting previously unselected package git-man. Preparing to unpack …/git-man_1%3a2.17.1-1ubuntu0.1_all.deb … Unpacking git-man (1:2.17.1-1ubuntu0.1) … Selecting previously unselected package git. Preparing to unpack …/git_1%3a2.17.1-1ubuntu0.1_amd64.deb … Unpacking git (1:2.17.1-1ubuntu0.1) … Setting up git-man (1:2.17.1-1ubuntu0.1) … Setting up liberror-perl (0.17025-1) … Setting up winbind (2:4.7.6+dfsg
I think the title should specify “and configure” as well since we’re configuring our email address as well. Installation is just apt install git but the articles tells a lot more.
Try DigitalOcean for free
Click below to sign up and get $100 of credit to try our products over 60 days!
Источники информации:
- http://www.geeksforgeeks.org/how-to-install-configure-and-use-git-on-ubuntu/
- http://phoenixnap.com/kb/how-to-install-git-on-ubuntu
- http://www.digitalocean.com/community/tutorials/how-to-install-git-on-ubuntu-18-04-quickstart
- http://www.digitalocean.com/community/tutorials/how-to-install-git-on-ubuntu-18-04