Categories
Life hack

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.

In this article, we will discuss the concept of Git tags and how the git tag command does work. We will cover various kinds of tags, how to create new tags, tag listing, and deletion of a tag, and more in this article. A few commands we have executed on the Ubuntu 20.04 system, which we will elaborate on in the rest of the section.

Create a new Tag

There are following two different types of Git tags:

  1. Annotated tags
  2. Lightweight tags

Annotated tags

The annotated tags are saved as a full object in the database of Git. These types of tags store some extra metadata information such as the name of the tagger, tagger email id, and date. Annotated tags stores with a tagging message. It is best practice suggested in git is to store git tags in the form of annotated tags over lightweight. Using the annotated tags, you can store all the associated meta-data in the database.

To create an annotated tag, open the terminal application by pressing Ctrl+Alt+t and run the following command:

In the above command, we have tagged the current HEAD by using the git tag command. The user provides a tag name ‘Release_1_0’ with the -a option, and the tag message is provided with the –m option.

Lightweight tags

This type of tags is used for ‘bookmarks’ to a commit; Lightweight tags are just a name or a specific pointer to a commit. Lightweight tags are useful for quick link creation to relevant commits.

The following command is used to create lightweight tags:

Example:

In the following example, let’s suppose we have created a lightweight tag with the name ‘Release_1_0’.

These types of tags are stored in the current working .git project repository.

View Tags

Once you have created tags, you can show tag details by using the following command:

How to install software using git on linux

In the above command, we have printed the tag ‘Release_1_0’ details. In the following image, the tag details are displayed:

Listing Tags

You can also display all the tags names by using the following Git tag command with option –l:

Removing or Delete Tags

First, to list all store tags in a repository, run the below-given command:

Now, using the following command, you can remove or delete tags from the remote as well as the local repository.

Conclusion

We have learned how to use Git tags in this article. Tagging is a useful feature through which you can create a clone image of a Git repo. You can give a better, some meaningful name to a specific git project. According to your convenience, you can create two different types of tags, annotated or lightweight, which we have discussed above. I hope now you have a better understanding of the usage of Git tags in your Git project repo.

About the author

How to install software using git on linux

Karim Buzdar

Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.

How to install software using git on linux

From the late ’80s when version control software first started developing, Git remains the most easy to use code change tracking tool.

Services like Github and Gitlab offer storage of code in a repository, often referred to as a ‘Remote’ repository. They act as central storage of code; Git can sync a local code with the central code to manage even complex changes by multiple users properly.

Installation

On Ubuntu, Debian, and similar distributions, you can install Git by running:

Note: For older Ubuntu versions (version 14.04 and below), you need to use apt-get instead of apt .

On CentOS, Fedora, and other Red Hat based distributions, you can install Git by running:

Basic Git Commands

Let us see some basic commands in git which will help us start tracking changes in our code.

To enable git on a local folder, run the command below inside the folder in Terminal.

It creates a hidden folder, .git , which contains git configuration and information on change tracking, if files are added for change tracking afterwards. Use it to initialize git on a local project.

To clone/download a remote folder and initialize git on it, run the command below:

, is the url of a project on a remote repository. It will download the remote project on local system, and create a git initialized folder with the project name.
Note that there is no need to run git init after a project is cloned.

To pull changes from a remote directory using git, run the command below:

The pull command of git will pull all the changes on remote repository since last pull or clone. User must first commit his local changes before he pulls from remote, so that local changes are not lost.

In case of a conflict between pulled changes and local changes, git will notify where the conflict is happening and will ask user to modify the file manually.

To add a file or folder to git, run the command below:

The above command adds the file or folder specified in command to the Git staging area. Git staging area refers to the state when a file is being tracked for changes. Use git add . for adding all files in the current folder to staging area.

To check the status (tracking state) of your files in a working directory, run the command below

It shows the tracking status of current folder; which files have been changed since last commit and which files have not been added in the staging area.

To commit changes in git, use the command below:

The commit command will commit the file changes, meaning, the staged change has been made permenant now. It is mandatory to provide a message string with each commit, which should describe the changes being commited in that commit; this is to keep a log of changes.

To push changes to a remote repository using git, run the command below:

After code has been commited, user can push the commited changes to remote repository. Note that user must first pull the code before pushing, so that his local project contains all the remote changes if there are any.

These are some of the basic commands with which a user can start using Git for change tracking. More commands include change stashing, project branching and other features of Git, which can be found in the Git man page.

Git, developed by Linus Torvalds, is the most popular distributed system for version control. Git is a very efficient platform for open-source projects. Using Git, you can collaborate with the other developers, upload the new changes, keep track of the changes, and many more.

Installing Git on Linux Mint

The Git is included in Linux Mint 20 standard repositories can be installed easily using the apt command.

As always, update and upgrade your Linux Mint 20 system before installing the Git package.

Type the below-given command to update the apt package listing:

How to install software using git on linux

Next, upgrade the system with the command:

How to install software using git on linux

After successfully updating and upgrading the Linux Mint 20 system, install Git with the command:

How to install software using git on linux

Press ‘y’ to continue installing Git.

When the Git is successfully installed, verify the installation:

Git 2.25.1 is successfully installed on my Linux Mint 20.

Configuring the Git on Linux Mint 20

Next, we have to configure Git. The Git can be configured from the command line. Configuring Git refers to setting a name and email address. The name and email are used while committing changes on the Git repository.

Fire up the terminal and use the below-given command syntax to set a global commit name:

Type the below-given command to set the global commit email:

Finally, when the global commit name and email are set, run the below-given command to check and verify the changes:

The output shows that the global commit name and email are sent successfully.

If the changes are not made correctly, or you want to change the global commit name and email any time, then you can edit the configuration settings any time by using the command:

The Git configuration file is opened in the nano editor. You can make any changes in the Git configuration file if you wish to.

Conclusion

Installing Git on Linux Mint 20 is very straightforward. Git is part of the Linux Mint 20 base repositories and can be downloaded and installed with apt command.

About the author

How to install software using git on linux

Kamran Sattar Awaisi

I am a software engineer and a research scholar. I like to write article and make tutorial on various IT topics including Python, Cloud Computing, Fog Computing and Deep Learning. I love to use Linux based operating systems.

If you’re a developer, then you know your way around development tools. You’ve spent years studying one or more programming languages and have perfected your skills. You can develop with GUI tools or from the command line. On your own, nothing can stop you. You code as if your mind and your fingers are one to create elegant, perfectly commented, source for an app you know will take the world by storm.

But what happens when you’re tasked with collaborating on a project? Or what about when that app you’ve developed becomes bigger than just you? What’s the next step? If you want to successfully collaborate with other developers, you’ll want to make use of a distributed version control system. With such a system, collaborating on a project becomes incredibly efficient and reliable. One such system is Git . Along with Git comes a handy repository called GitHub , where you can house your projects, such that a team can check out and check in code.

I will walk you through the very basics of getting Git up and running and using it with GitHub, so the development on your game-changing app can be taken to the next level. I’ll be demonstrating on Ubuntu 18.04, so if your distribution of choice is different, you’ll only need to modify the Git install commands to suit your distribution’s package manager.

Git and GitHub

The first thing to do is create a free GitHub account. Head over to the GitHub signup page and fill out the necessary information. Once you’ve done that, you’re ready to move on to installing Git (you can actually do these two steps in any order).

Installing Git is simple. Open up a terminal window and issue the command:

This will include a rather large number of dependencies, but you’ll wind up with everything you need to work with Git and GitHub.

On a side note: I use Git quite a bit to download source for application installation. There are times when a piece of software isn’t available via the built-in package manager. Instead of downloading the source files from a third-party location, I’ll often go the project’s Git page and clone the package like so:

Where ADDRESS is the URL given on the software’s Git page.
Doing this most always ensures I am installing the latest release of a package.

Create a local repository and add a file

The next step is to create a local repository on your system (we’ll call it newproject and house it in

/). Open up a terminal window and issue the commands:

Now we must initialize the repository. In the

/newproject folder, issue the command git init . When the command completes, you should see that the empty Git repository has been created ( Figure 1 ).

How to install software using git on linuxFigure 1: Our new repository has been initialized.

Next we need to add a file to the project. From within the root folder (

/newproject) issue the command:

You will now have an empty file in your repository. Issue the command git status to verify that Git is aware of the new file ( Figure 2 ).

How to install software using git on linuxFigure 2: Git knows about our readme.txt file.

Even though Git is aware of the file, it hasn’t actually been added to the project. To do that, issue the command:

Once you’ve done that, issue the git status command again to see that readme.txt is now considered a new file in the project ( Figure 3 ).

How to install software using git on linuxFigure 3: Our file now has now been added to the staging environment.

Your first commit

With the new file in the staging environment, you are now ready to create your first commit. What is a commit? Easy: A commit is a record of the files you’ve changed within the project. Creating the commit is actually quite simple. It is important, however, that you include a descriptive message for the commit. By doing this, you are adding notes about what the commit contains (such as what changes you’ve made to the file). Before we do this, however, we have to inform Git who we are. To do this, issue the command:

Where EMAIL is your email address and FULL NAME is your name.

Now we can create the commit by issuing the command:

Where Descriptive Message is your message about the changes within the commit. For example, since this is the first commit for the readme.txt file, the commit could be:

You should see output indicating that 1 file has changed and a new mode was created for readme.txt ( Figure 4 ).

How to install software using git on linuxFigure 4: Our commit was successful.

Create a branch and push it to GitHub

Branches are important, as they allow you to move between project states. Let’s say you want to create a new feature for your game-changing app. To do that, create a new branch. Once you’ve completed work on the feature you can merge this feature from the branch to the master branch. To create the new branch, issue the command:

git checkout -b BRANCH

where BRANCH is the name of the new branch. Once the command completes, issue the command git branch to see that it has been created ( Figure 5 ).

How to install software using git on linuxFigure 5: Our new branch, called featureX.

Next we need to create a repository on GitHub. If you log into your GitHub account, click the New Repository button from your account main page. Fill out the necessary information and click Create repository ( Figure 6 ).

How to install software using git on linuxFigure 6: Creating the new repository on GitHub.

After creating the repository, you will be presented with a URL to use for pushing our local repository. To do this, go back to the terminal window (still within

/newproject) and issue the commands:

Where URL is the url for our new GitHub repository.

You will be prompted for your GitHub username and password. Once you successfully authenticate, the project will be pushed to your GitHub repository and you’re ready to go.

Pulling the project

Say your collaborators make changes to the code on the GitHub project and have merged those changes. You will then need to pull the project files to your local machine, so the files you have on your system match those on the remote account. To do this, issue the command (from within

The above command will pull down any new or changed files to your local repository.

The very basics

And that is the very basics of using Git from the command line to work with a project stored on GitHub. There is quite a bit more to learn, so I highly recommend you issue the commands man git , man git-push , and man git-pull to get a more in-depth understanding of what the git command can do.

Learn more about Linux through the free “Introduction to Linux” course from The Linux Foundation and edX.

Git is a popular open source version control system like CVS or SVN. This article is for those, who are not familiar with Git. Here, we are providing you with basic steps of installing Git from source, Creating a new project, and Commit changes to the Git repository.

Difference between Git and other Version Control Systems

Most of the other version control systems, store the data as a list of files and changes are made to each file over time. Instead, Git thinks of its data more like a set of snapshots in a file system. Every time, it takes a snapshot of all your files (which look alike at that particular moment), it will be stored as a reference. If files are not changed, Git does not store the new snapshots. In this case, it just links to a previous snapshot of your file system.

Installing Git from Package Manager

Git is available with all the major Linux distributions. Thus, the easiest way to install Git is by using a Linux package manager. Use the following command to install git on Linux –

Use the following command to install git on Linux –

The output should be like this –

Installing Git from source

An alternate way is to install Git from source which should be like this –

The output should be like this –

Initial Configuration

Git is by default installed under /usr/bin/git directory on recent Linux systems.

Once the installation is done, verify it by using the following command –

The output should be like this –

To get the version number of Git, you can use the following command –

The output will be like this –

If you want to specify a User and Password information to Git repository, then use the following command –

For verifying Git configuration, use the following command –

The output should be like this –

The above information is stored in the .gitconfig file under the home directory. To verify, use the following command –

The output should be like this –

Create a Project

To create a Git repository project, we should attach any local directory. Suppose, if project directory is located under /home/tp/projects path, first go into that directory using CD command and execute git init command as shown below –

The output should be like this –

The above command creates a .git directory under projects folder. To verify, use the following command-

The output should be like this –

Add Files to the Project

Once a project is created, it will initialize the project using “git init”. Now, add your files to your project directory. For adding .txt files to Git repository, use the following command –

Once adding process is done to the repository, you should commit these files as shown below command –

The sample output should be like this –

Congratulations! Now, you know “How to setup git on Linux” . We’ll learn more about these types of commands in our next Linux post. Keep reading!

In this article, we will learn about “how to use the Yum command” for installing the packages. Also note that, the repositories on the Cent OS 6.7 YUM (Yellowdog Update Modified) is a tool used to develop by Redhat. You can use this materials for learning the YUM.

Managing Software with YUM

Use the yum utility to install or modify the software on your system in the following ways –

  • New software installation from repositories.
  • Installing software from an individual package file.
  • Updating the existing software on your system.
  • Removing unwanted software from your system.

Installing Software from a Package File

The yum commands used in this is to use repositories as a package sources and the yum will install software from an individual package file. To use yum for a specific function and for one or more packages or the package groups. Each section below will shows some examples.

The following sections along with examples will help you to understand “how to use yum for a specific function and or for multiple packages or package groups”.

Yum always downloads the latest package information from the repositories. If the system uses a slow network connection, then yum may require some time to download the repository and find the indexes and the header files for each package.

The yum utility will search for data to determine the best repository and proceeds with the required installation and will show the result to display the transaction for you. The result may include the installations, updates, or removal of the packages, in order to resolve and install the software dependencies.

Below is an example of installing a unity using install option ‘tsclient‘ utility.

It will review the list of changes and packages needed to upgrade, and when we press y to accept and begin the process. If you press N or Enter, then yum will not download or change any packages.

Package Versions

The yum will only display and uses the newest version of the package, unless we specify about installing the older version. The yum also imports the repository of public keys if it is not installed on the RPM keyring.

Below is an example of the public key import:

Importing the YUM Public Key

After we check the public key, then press y to import the key and authorize the key to use. If you press N or Enter, yum stops importing the key and stops the installation of packages.

To ensure that, the downloading of packages is genuine, yum verifies all digital signatures of each package with the public key provided by the provider. Once all of the packages required for the installation are successfully downloaded and verified, yum will install them to your system.

Downloads are Cached

The yum will keep downloading the data files and packages for the future. You may take a backup of the packages from the repository cache directories which locates at /var/cache/yum/, and we can use them to install elsewhere if required. If you remove the package from the cache, it won’t affect the copy of the installed software on the system.

Installing New Software with YUM

To install the package mysql, enter the command:

Installing Software in a Group

If you want to install the package group MySQL Database, enter the below command:

Updating Software uses yum

To update the HTTP package which is already installed with the latest version, type:

If the software is in use and when we update it, the older version remains active till the application or service is restarted. Updates like the kernel or system software will take effect when the machine gets rebooted.

If we want to update all of the packages in the package group “MySQL Database”, we have to run the command:

Removing the Software using YUM

To remove the software installed, the yum examines your system for both the specified software for removal and any software which effects the dependencies. Also note that, if you remove the software, then both the software and its dependencies gets deleted.

To remove the HTTP package from your system, use the command:

To remove all of the packages in the package group “MySQL Database”, Run the below command

The removal process will leave the user data in place, but it will remove configuration files in. If a package removal has the option of not removing the configuration file, and we reinstall the packages later, it may use the old configuration files only.

After reading this article you are able to use the Yum (Yellowdog Update and Modified) and command to install, upgrade, remove the softwares on Linux machines to manage the softwares and package requirement for the environment.

Installing Git

Before you start using Git, you have to make it available on your computer. Even if it’s already installed, it’s probably a good idea to update to the latest version. You can either install it as a package or via another installer, or download the source code and compile it yourself.

This book was written using Git version 2.8.0. Though most of the commands we use should work even in ancient versions of Git, some of them might not or might act slightly differently if you’re using an older version. Since Git is quite excellent at preserving backwards compatibility, any version after 2.8 should work just fine.

Installing on Linux

If you want to install the basic Git tools on Linux via a binary installer, you can generally do so through the package management tool that comes with your distribution. If you’re on Fedora (or any closely-related RPM-based distribution, such as RHEL or CentOS), you can use dnf :

If you’re on a Debian-based distribution, such as Ubuntu, try apt :

For more options, there are instructions for installing on several different Unix distributions on the Git website, at https://git-scm.com/download/linux.

Installing on macOS

There are several ways to install Git on a Mac. The easiest is probably to install the Xcode Command Line Tools. On Mavericks (10.9) or above you can do this simply by trying to run git from the Terminal the very first time.

If you don’t have it installed already, it will prompt you to install it.

If you want a more up to date version, you can also install it via a binary installer. A macOS Git installer is maintained and available for download at the Git website, at https://git-scm.com/download/mac.

How to install software using git on linux

Installing on Windows

There are also a few ways to install Git on Windows. The most official build is available for download on the Git website. Just go to https://git-scm.com/download/win and the download will start automatically. Note that this is a project called Git for Windows, which is separate from Git itself; for more information on it, go to https://gitforwindows.org.

To get an automated installation you can use the Git Chocolatey package. Note that the Chocolatey package is community maintained.

Installing from Source

Some people may instead find it useful to install Git from source, because you’ll get the most recent version. The binary installers tend to be a bit behind, though as Git has matured in recent years, this has made less of a difference.

If you do want to install Git from source, you need to have the following libraries that Git depends on: autotools, curl, zlib, openssl, expat, and libiconv. For example, if you’re on a system that has dnf (such as Fedora) or apt-get (such as a Debian-based system), you can use one of these commands to install the minimal dependencies for compiling and installing the Git binaries:

In order to be able to add the documentation in various formats (doc, html, info), these additional dependencies are required:

Users of RHEL and RHEL-derivatives like CentOS and Scientific Linux will have to enable the EPEL repository to download the docbook2X package.

If you’re using a Debian-based distribution (Debian/Ubuntu/Ubuntu-derivatives), you also need the install-info package:

If you’re using a RPM-based distribution (Fedora/RHEL/RHEL-derivatives), you also need the getopt package (which is already installed on a Debian-based distro):

Additionally, if you’re using Fedora/RHEL/RHEL-derivatives, you need to do this:

due to binary name differences.

When you have all the necessary dependencies, you can go ahead and grab the latest tagged release tarball from several places. You can get it via the kernel.org site, at https://www.kernel.org/pub/software/scm/git, or the mirror on the GitHub website, at https://github.com/git/git/releases. It’s generally a little clearer what the latest version is on the GitHub page, but the kernel.org page also has release signatures if you want to verify your download.

Then, compile and install:

After this is done, you can also get Git via Git itself for updates:

To install Git Repository on Linux Mint 18.3

Git is an open source and most popular Version Control System. When a developer develops software he or she can store the software with its source code in Git repository. You can create a duplicate copy of the stored software to make changes to source code over time. The advantage of Git repository is, even if you make a mistake on source code while editing, it will not affect your live software and you can fix the mistake by comparing it with previously released source code. This tutorial covers the method to install Git Repository on Linux Mint 18.3.

Installing Git Repository

Before you begin the installation process, make sure you update your repository by making use of the following command.

Once it’ s done, you shall add the necessary repository by making use of the following command.

After that, you need to update the system again.

Once it is done, you need to install Git by making use of the following command.

Once the installation is completed, you need to confirm installation by making use of the following command.

Now, you need to configure set-up of the Git repository which you can accomplish with the help of the following command.

Later, you need to configure your global username of the Git repository.

You need to add the username.

Now open git configuration file.

You can see that the Git configuration is done.

With this, the method to install Git repository on Linux Mint comes to an end.