Everything Beginners Should Know About Installing Software Using GIT

How to work with Git software repositories

Hands using computer to config system vector illustration.Setting personal computer concept
VVadyab / Getty Images

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 home to 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 Find Programs Using GIT

Visit the explore webpage at GitHub to see the featured and trending depositories 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. Click the menu icon at the top of the screen to reach the search field where you can search for a specific program or any category of software available on the site. 

An Example of Cloning A Git Repository

To download an application, you clone it. The procedure is simple, but you must have Git installed on your system. Using the small command line program called cowsay, which is used to display a message as a speech bubble from an ASCII cow, here's an example of how to find and clone a program from GitHub.

Type cowsay in the Git search field. You will notice that there are a number of versions available you can choose. The one for this example, which uses Perl, takes you to a page with several files.

To clone this particular cowsay repository, enter the following command:

 git clone git://github.com/schacon/cowsay

The git command runs Git, the clone command clones the repository onto your computer, and the last part is the address to the project you want to clone.

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, whereas the cowsay project in this example requires you to run a shell script.

So how do you know what to do?

In the folder that you cloned, there should be a cowsay folder. If you navigate to the cowsay folder using the CD command and then do a directory listing, you should see either a file called README or a file called INSTALL or something that stands out as a help guide.

In the case of this cowsay example, there is both a README and an INSTALL file. The README file shows how to use the software, and the INSTALL file gives the instructions to install cowsay. In this case, the instruction is to run the following command:

sh install.sh

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.

How to Run Cowsay

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

cowsay hello world

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

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:

nano cowsay

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:

getopts('bde:f:ghlLnNpstT:wW:y', \ %opts);

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

getopts('bde:f:ghlLnNpstT:wW:yc', \ %opts);

Between lines 51 and 58 you see the following lines:

$borg = $opts{'b'};
$dead = $opts{'d'};
$greedy = $opts{'g'};
$paranoid = $opts{'p'};
$stoned = $opts{'s'};
$tired = $opts{'t'};
$wired = $opts{'w'};
$young = $opts{'y'};

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:

$borg = $opts{'b'};
$dead = $opts{'d'};
$greedy = $opts{'g'};
$paranoid = $opts{'p'};
$stoned = $opts{'s'};
$tired = $opts{'t'};
$wired = $opts{'w'};
$young = $opts{'y'};
$cyclops = $opts['c'];

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

The code looks like this:

sub construct_face {
  if ($borg) { $eyes = "=="; }
  if ($dead) { $eyes = "xx"; $tongue = "U "; }
  if ($greedy) { $eyes = "\ $\ $"; }
  if ($paranoid) { $eyes = "@@"; }
  if ($stoned) { $eyes = "**"; $tongue = "U "; }
  if ($tired) { $eyes = "--"; }
  if ($wired) { $eyes = "OO"; }
  if ($young) { $eyes = ".."; }
}

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 :

sub construct_face {
  if ($borg) { $eyes = "=="; }
  if ($dead) { $eyes = "xx"; $tongue = "U "; }
  if ($greedy) { $eyes = "\ $\ $"; }
  if ($paranoid) { $eyes = "@@"; }
  if ($stoned) { $eyes = "**"; $tongue = "U "; }
  if ($tired) { $eyes = "--"; }
  if ($wired) { $eyes = "OO"; }
  if ($young) { $eyes = ".."; }
  if ($cyclops) { $eyes = "()"; }
}

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

sh install.sh

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