How to install software using git on linux

How to work with Git software repositories

  • Tweet
  • Share
  • Email

Open-source Git is the most used version control system in the world. The mature project was developed by Linus Torvalds, the creator of the Linux operating system, and it is used by an enormous collection of software projects—both commercial and open-source—that depend on Git for version control.

This guide shows how to get a project from Git, how to install the software on your system and how to change the code, which requires knowledge of programming.

How to install software using git on linux

How to Find Programs Using Git

Visit the explore webpage at GitHub to see the featured and trending repositories as well as links to guides and training. Look at the various categories for applications you want to download and have a go at using, changing, compiling and installing. Use the search field at the top of your screen where you can find a specific program or any category of software available on the site.

An Example of Cloning a Git Repository

In Git terminology, downloading a repository is “cloning” it. That’s because you’re making an exact copy of the Git repository on your computer. The procedure is simple, but you must have Git installed on your system.

If you’re working on a Linux system, like Ubuntu, you’re in luck. Git is available in your distribution’s package repositories. Install it the way you normally would any other application. Nearly every distribution calls the package ‘git.’

Git is free and open source, so it won’t cost you a penny on any platform. Windows users can find the latest version on the Git Windows download page. Mac users can find it on the Git for Mac download page.

This guide will use the small command line program called cowsay, which displays a message as a speech bubble from an ASCII cow.

To start, type cowsay in the GitHub search field. You will notice that there are a number of versions available you can choose. The example in this guide is going to work one from the developer “Schacon.” It’s a fairly simple version written in Perl, so it should be relatively easy to work with and modify.

How to install software using git on linux

To clone this particular cowsay repository, enter the following command into a terminal window.

The git command runs Git. Then, it’s told to clone a repository, and the link to the Cowsay repository on GitHub is provided. You can find the Git clone link on GitHub under Clone or download, just above the table displaying the contents of a repository.

How to install software using git on linux

How to Compile and Install the Code

Install the application first just to make sure it runs. How you do this depends on the project you have downloaded. For example, C projects will probably require you to run a makefile with the make command, whereas the cowsay project in this example requires you to run a shell script.

So how do you know what to do?

You just cloned the repository into whichever directory you were in when you ran the ‘clone’ command. Everything from the repository will be in a new directory named after that repository. In this case, it’s cowsay. Change directories into the cowsay folder, and list out its contents.

During the installation, you are asked whether you are happy for it to install cowsay to the default folder supplied. You can either press Return to continue or enter a new path. Should you want the default path, you’ll probably need to rerun the command with ‘sudo.’

How to install software using git on linux

How to Run Cowsay

All you have to do to run cowsay is type the following command:

The words hello world appear in the speech bubble from a cow’s mouth.

How to install software using git on linux

Changing Cowsay

Now that you have cowsay installed, you can amend the file using your favorite editor. This example uses the nano editor as follows:

How to install software using git on linux

You can supply switches to the cowsay command to change the eyes of the cow.

For example cowsay -g shows dollar signs as the eyes.

You can amend the file to create a cyclops option so that when you type cowsay -c the cow has a single eye.

The first line you need to change is line 46 which looks as follows:

These are all the available switches that you can use with cowsay. To add the -c as an option, change the line as follows:

Between lines 51 and 58 you see the following lines:

As you can see, there is a variable for each of the options that explains what the switch will do. For example $greedy = $opts[‘g]’;

Add one line for the -c switch amendment as follows:

On line 144, there is a subroutine called construct_face which is used to construct the cows face.

The code looks like this:

For each of the variables specified earlier, there is a different pair of letters that is placed in the variable $eyes.

Add one for the $cyclops variable :

Saved the file and run the following command to reinstall cowsay.

Now, when you run cowsay -c hello world, the cow has only one eye.

GitHub is the most used version control system in the world. This project was developed by Linus Torvalds, the creator of the Linux operating system, and it is used by an enormous collection of software projects both commercial and open-source that depend on Git for version control.
– For how to install Git on macOS, see https://techdirectarchive.com/2018/12/13/git-osx-installation/
– For how to use AWS CodeCommit, see https://techdirectarchive.com/2018/07/13/using-aws-codecommit-vsc/

Note: GitHub is not a store app 😉 There is no “guide on how to install a program from GitHub”. Github is a platform where developers put their code*. Any code. It could be a Windows program. It could be an Android program. It could be HTML. It could be a library. It could be a snippet of code. It could be coded in a language invented by the developer.

Note: Some repositories have a Readme, see an example here for an example of a read me and this guides you on how to compile or install the program.
– This is up to the developers that posted the code. If there isn’t a readme then try to figure out what kind of code it is.

Install Git: To install Git, download Git for Windows in the following location.

– Click on run (If you wish to save and then execute you can as well)
– And follow other installation processes. It is simple, because of this I will not be explaining all the screenshots.
– Click on next

Screenshot 2020 05 23 at 16.59.53

Choose to use any of the transport type
– Select the option to use OpenSSL
– Ensure you use same settings as shown below unless you extremely know what you are doing.

  • Screenshot 2020 05 23 at 17.07.44

Enable the following configuration option and
– Click on Install
– Finally, you can launch the Git Bash by click on Next in as shown below.

    Screenshot 2020 05 23 at 17.10.53

Next, you will have to clone the repository. This repository contains the source code for the Package.
– Navigate to the URL here. Note, this repository will be different from yours. Ensure to access the right repository and have it cloned.

Next, on the Git Terminal window, enter the following command (syntax) to clone your repositories.
– The git command runs Git. Then, it’s told to clone a repository, and the link to the Windows Package Installer repository on GitHub is provided.

Now, we need to compile and install the code.
– Access the location of the cloned repo. In my case, I ran the “pwd” to determine the current directory i was and to determine where cloned repo was stored. For me, it was saved to this location C:\Users\TechDirectArchive

Tip! In whichever directory you were, that will be the location of your cloned repository (directory). Everything from the repository will be in a new directory named after that repository.

Screenshot 2020 05 23 at 18.22.50

I hope you found this blog post helpful. If you have any questions, please let me know in the comment session.

I would like to install custom source from a git repository, but using my package manager (emerge for portage).

Background

I have installed Gentoo using EFI using Sakaki’s tutorial, so I have already emerged dev-vcs/git .

The packages that I want are for installing Canonical’s Snapd (background reading from Ars Technica), and their instructions are:

‘# enable the snapd systemd service:

sudo systemctl enable –now snapd.service

Steps Tried that Didn’t Work

Try 1

First I tried to add the prerequisite git .ebuilds as repositories by putting them in my /etc/portage/repos.conf/ directory (two separate entries). I’ll post one here as an example:

I synced the repos, emaint sync –repo zyga-snap-confine . And then I tried finding the packages that I wanted via both emerge –search and eix . No luck.

It tossed errors about missing layout, a master = gentoo entry. I realize that there was missing metadata, but I had high hopes.

Try 2

I finally found a reference with what to do with an ebuild. In the official Gentoo Wiki, and from other posts here (Installing Git, Curl, and Expat from Source) and here (How to package software in Funtoo/Gentoo?), I decided to:

However, it returned errors:

Preferred Solution

I’m relatively new to Gentoo and am self-taught on Linux, and I couldn’t find a tutorial on repo maintenance in the Gentoo forums (there is a developer’s guide, but it assumes a lot of knowledge). An ideal answer will provide both the cli method (I assume using git clone . and ./configure ?) as well as the package manager version.

Even if I have to create my own git repository to add missing metadata and layout files – I would prefer to manage the snapd installation that way.

1 Answer 1

Based off of @likewhoa comments above, the structure of the ebuild needed to be massaged. The creators did not have recent portage structure in mind when creating their git repositories.

For Command-line

(an ebuild without portage directory structure)
Within /usr/local/portage/ I decided that snap-confine belonged under category sys-apps

From bash root prompt:

As it turns out, the .ebuild wasn’t properly formed with correct dependencies, but I think these steps provide a good tutorial – based off of:

For Portage management

Based off of other Gentoo repositories, I recommended to the developer to create a single repo containing both the snap-confine and snapd ebuilds under the package categories sys-apps and app-emulation , respectively.

Developers must use all available tools to make quality software. Some of these tools do not go directly to the software or the code but to its management. For example, version control is important to ensure that changes are made to the code in an orderly fashion. In this segment, Git seems to be the most logical alternative for this task. So in this post, we will show you how to install Git on Ubuntu 18.04 and Linux Mint 19.

Git is a free and open source distributed version control system. It is perhaps the most popular within the branch as millions of developers use it to control software versions. Ease of use, community support, and efficient version control are the main features of Git. In addition, it is open source and free, which makes it ideal for all projects.

Of course, Git is available for almost any Linux distribution. It also has versions for Windows or MacOS. So no matter what platform you develop on, you will always have the advantages of using Git.

As I mentioned earlier, Git is available for many Linux distributions. And Ubuntu is no exception. For Ubuntu and Linux Mint we have two different ways to install Git.

First, Git is in the official Ubuntu and Linux Mint repositories. However, the available version is somewhat outdated and the development of Git is quite active. Installing Git in this way is quite simple but will deprive you of having the latest version available with all its advantages.

So, open a terminal and run:

1.- Install Git from the main repositories

Then, check the installed version.

2.- Git version

As we can see, the version that is in the official repositories is 2.17. However, the latest version available is 2.21 at the time of writing this post.

Fortunately, there is a PPA for Ubuntu and Linux Mint that we can use to install the latest version of Git very easily.

So, open a terminal and run:

3.- Adding the external repository

Then, refresh the APT cache.

If you already have it installed, run this command.

Or, if you do not have it installed.

After that, check the installed version.

4.- Git latest version installed

So we can install Git on Ubuntu 18.04 and Linux Mint 19 using the PPA of the development team.

Git is quite a reference when it comes to version control. Many developers use it for their daily work and offer a great guarantee for it. In addition, installing it is quite simple and is within everyone’s reach.

How to install software using git on linux

Installing Git from Ubuntu Software APT

It is a recommended method to install the Git system from the Ubuntu Software repository.

Step 1:

As always, first, update and upgrade your APT.

Step 2:

The Git utility package is, by default, included in ubuntu’s software repositories that can be installed via APT. Just enter the following command to download and install Git.

Git requires root/sudo privileges to be installed so, enter the password to continue the installation.

Step 3:

When Git gets installed, you can check its verification with the following command

Configuring Git

You can configure Git through the terminal/command-line window. It requires a global username that acts as a commit name and an email address.

Step 1:

Enter the following command to set a username, replace the content inside the “Younis said” with your name.

Step 2:

Enter the following command to set a global user email, replace the content inside the “[email protected]” with your user email.

Step 3:

Lastly, check for the changes you just made by using the following command. It lists out the changes made to the Git configuration file.

Step 4 (optional):

You can also edit these settings any time for that you have to change it via “git config command” in the terminal window.

How to install software using git on linux

Conclusion:

Git is very easy to install on Ubuntu, just needs 4 commands to install and configure it. You just need an APT command to download and install the stable version from the Ubuntu repository

About the author

How to install software using git on linux

Younis Said

I am a freelancing software project developer, a software engineering graduate and a content writer. I love working with Linux and open-source software.

If you have ever been active in the world of software development, you know the importance of keeping track of different versions of your project, which in turn helps you to keep that flow of development as well as to provide better usability. In addition, if you have ever approached experienced people in this field, they would prefer Git, in most cases. Technically speaking, Git is one widely used tool for distributed version control as well as source-code-management purposes with ease. On the other hand, GitHub is a hosting platform for software projects, which make use of Git for version controlling. So if you haven’t signed up for Github, we highly recommend you do so at https://github.com/signup/free.

All repositories in the basic plan of GitHub are public whereas you will have to purchase the premium plan for building private repositories. Rather than a hosting service, the service is something further useful, as it helps in building a community-level development as well as easy publicizing of your software-development projects, based on Git. When both these projects are combined together, it brings an awesome solution for the easy management of your projects. Earlier, we had published one tutorial for using Git in your Windows-powered PC. Now, it is time for Linux, which is also from the open-source power. Hope this tutorial will help you in setting up the special environment in your Linux PC and enabling version controlling in an effective manner.

Basics of Git

1. Creating a Repository

You can create a repository on Github, but you will need to be logged in on Github. If you don’t have an account, you can create one at github.com.

How to install software using git on linux

Here you need to provide a name for your repository, and some description. You can choose to make your repo Public or Private.

2. Set up Your Repository

Once, you have created the repo, Github will provide the instructions to setup your repo with on your local machine.

How to install software using git on linux

If you do not have Git setup on your machine, follow the instructions at https://help.github.com/articles/set-up-git. Now, let’s start with creating a directory and initializing Git.

How to install software using git on linux

Add a ‘index.php’ file to our directory.

Now initialize the directory with:

How to install software using git on linux

Add the files with:

This will include all the files in our directory.

How to install software using git on linux

Now, let’s make our first commit with:

How to install software using git on linux

Add the origin to our repository with:

How to install software using git on linux

Now lets, push the changes to our repository online:

This will save all our local changes to our repository online.

How to install software using git on linux

Please comment if you have any issues setting up Git on your local machine.

Benefits of Using Git

Git is an open-source tool and is free for anyone to use. Almost all the changes are done locally and there is no need for propagating those changes to any central server as well. A project can be edited locally and can be later saved to a server, in which every contributor can see and track these changes. Unlike centralized VCS, Git does not have a single point of failure.

Since Git has distributed architecture, everyone can get the latest snapshot of the work, as well as the entire repository contents and its history. If for some reason the server goes down, a copy from the client can be used as a backup and restore to the server.

To store and identify objects within its database, Git uses a cryptographic hash function known as the SHA-1 hash. Before storing any data, Git checks summed it and uses this checksum to refer to it.

It is very easy to install and does not require high-end hardware on the client-side. Many online hosting services like GitHub provide services to host your Git project online for remote access. One can get an entire backup of a repository on their local computer. Changes made by a contributor to a repository become its part after a commit operation.

The commit operation makes a snapshot of the current state in the repository or the database. After we have worked on our project locally, we can publish local commits to our remote Git database or repository using the push command.

What Will We Cover?

In this guide, we will see how we can install and configure Git on Fedora 33 OS. We will install Git from the official repository on Fedora, as well as from the source code downloaded from the Git official website. Let’s get started with the Git installation process.

Method 1. Installing Git from Fedora Repositories Using dnf/yum

This is a very simple method of installing Git. You just need to run the commands below:

Step 1. Update the available system packages with the following command:

Step 2. Now install git with the below command:

After the above command finishes, use the following command to check the installed version of Git:

How to install software using git on linux

That’s all! As you can see, Git already comes installed on Fedora 33, but if it is not, you can install it from the above command.

In this case, you want to uninstall Git, simply run the appended command below:

How to install software using git on linux

Method 2. Building Git from source code on Fedora

Git can also be installed on Fedora from the available source code on the Git website. To install them from source code, follow the below procedure:

Step 1. Git requires several packages to be installed before we can install it from source code. Run the below command to install these dependencies:

Step 2. Once we have all the required dependencies in place, we can move on to download the source code. Run the following command to download the compressed tarball of Git source code:

Alternatively, you can also visit this link and manually download the file to your system. This is shown here:

How to install software using git on linux

Step 3. Extract the downloaded tar file with the below command:

Step 4. Now move to the extracted folder on the command line window:

Step 5. Run the make command:

Step 6. Run the config script:

How to install software using git on linux

Step 7. Run the make all command:

How to install software using git on linux

Step 8. Run the make install command:

How to install software using git on linux

Now, Git is installed on your system. Check the version from here:

Configuring Git settings on Fedora

After installing Git, we will need to add our username and email address to our Git account. This will enable us to commit our code properly. This information is used by Git with every commit we make.

Note: The Git username is not the same as that for GitHub.

To set these details, run the following commands:

Here replace “your-username” with a username of your choice and “[email protected]” with your email id. The global keyword will make this information be used by every change on your system. If you want to use different information for a project, then simply remove the global keyword when you are inside that specific project.

Let’s add a sample username and email as:

Run the following command to check if these settings worked correctly:

This is shown below:

How to install software using git on linux

Conclusion

Congratulations, you have now successfully installed Git on your Fedora OS. If you have followed this tutorial properly, you will have noticed that Method 1 is very straightforward for installing Git. You only need to run a simple command to get the Git on your system. Meanwhile, Method 2 is a long way route for installing Git, and it is recommended only for advanced users and system administrators. The benefit of using this method is that you can get its latest available version. For example, in Method 1, the version of Git installed from the official repository is 2.28.0, whereas in Method 2 we have version 2.30.1.

About the author

How to install software using git on linux

Ali Imran Nagori

Ali imran is a technical writer and Linux enthusiast who loves to write about Linux system administration and related technologies. You can connect with him on LinkedIn
.

Some commands require extra dependencies which are unavailable in some platforms. You may need to install them manually.

Those dependencies are listed below:

Installing with a package manager

Note that only the Homebrew package is maintained by the git-extras developers directly. Other packages are maintained by the distribution’s packagers or third-party volunteers.

Substitute your openSUSE version in the command below (in this case we are considering openSUSE Leap 15.2):

Abdullah has written a Pkgfile for his beloved distro.

Installing from Homebrew will not give you the option omit certain git-extras if they conflict with existing git aliases. To have this option, build from source.

  • git-extras
  • git-extras-git

First, please install Git for Windows 2.x from ‘https://github.com/git-for-windows/git/releases’. Second, clone the git-extras repo into any folder you like.

After that, execute the install.cmd in the command prompt. If you installed git as admin, you need to run this prompt as admin, too. Per default, it finds a Git for Windows 2.x if it’s in the path (first path in where git.exe wins) or installed in the default location %ProgramFiles%\Git . The fallback is C:\SCM\PortableGit . If you didn’t install git into one of these dirs, you have to supply the path for the install location, e.g. if git is installed in c:\git :

Last, to use git summary and git ignore-io , you need to copy column.exe from a msys2 installation from folder-your-msys2-installed/usr/bin to folder-your-git-installed/usr/bin or wait for git 2.7.1, which will include column.exe.

Use the instructions to build from source below. Make sure you are using gmake (GNU make ) instead of make .

Building from source

Read Dependencies and ensure they are installed.

Obtain the git-extras source by cloning its GitHub repo or downloading a tarball of a release. Then install it by doing make install from the source tree.

By default, git-extras is installed under /usr/local . To install it at an alternate location, specify a PREFIX when calling make .

If you want to relocate the bulk of the installation but still have configuration files installed to the system /etc dir or other alternate location, you can specify SYSCONFDIR in addition to PREFIX .

See the Makefile for details on advanced configuration options.

Installing from network

Installing as Zsh plugin

ZInit can install git-extras by using:

/.zinit/polaris by default. Use zinit update tj/git-extras to update. This method installs in $HOME , so you don’t need to ask administrator to install package.

If you installed git-extras with a package manager, use that package manager’s tools to update it.

If you installed git-extras from source, you can run git-extras update to update it to the latest release. Be aware that this may lose any configuration options you specified during the original installation.

  • © 2021 GitHub, Inc.
  • Terms
  • Privacy
  • Security
  • Status
  • Docs
  • Contact GitHub
  • Pricing
  • API
  • Training
  • Blog
  • About

You can’t perform that action at this time.

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.

Git isn’t yet a default option on computers, so it will need to be installed and configured. Like other software, it’s important to keep Git up to date. Updates protect from security vulnerabilities, fix bugs, and provide access to new features.

The recommended method of installing and maintaining Git is provided for three major platforms below.

Windows

Download and install Git for Windows. Once installed, Git will be available from the command prompt or PowerShell. It is recommended that the defaults are selected during installation unless there is good reason to change them.

Git for Windows doesn’t automatically update. To update Git for Windows, download the new version of the installer, which will update Git for Windows in place and retain all settings.

macOS

macOS 10.9 (Mavericks) and higher will install Git the first time it is attempted to be run from the Terminal. While this is an easy way to get Git on the system, it doesn’t allow for control over how often updates or security fixes are applied.

Instead, it is recommended that Git be installed through Homebrew and that Homebrew tools are used to keep Git up to date. Homebrew is a great way to install and manage open source development tools on a Mac from the command line.

Install Homebrew and run the following to install an up to date version of Git on the Mac:

> brew install git

To update the Git install, use Homebrew’s upgrade option:

> brew upgrade git

A graphical installer for Git on macOS is also available from the official Git website.

Linux

Use the Linux distribution’s native package management system to install and update Git. For example, on Ubuntu:

> sudo apt-get install git

Configure Git

Set up the name and email address before starting to work with Git. Git attaches this information to changes and lets others identify which changes belong to which authors.

Run the following commands from the command prompt after installing Git to configure this information:

> git config –global user.name “Jamal Hartnett”

> git config –global user.email “[email protected]

Visual Studio offers a great out of the box Git experienceВ without any additional tooling. Learn more in this Visual Studio Git tutorial.