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. The big, green button saying “Clone or download”, click it and choose “download zip”. Of course, for those using Git and Github, it would be appropriate to clone the repository.And, although appearing more advanced, cloning has the definitive advantage that you’ll enjoy the whole of the Github features.
This is, how I download various master branches from GitHub, and I aim to have a prettier script (and maybe more reliable?).
Can this be shorten to one line somehow, maybe with tar and pipe?
Please address issues of downloading directly to the home directory
~/
and having a certain name for the directory (mv
really needed?).shortershorter
3 Answers
The shortest way that seems to be what you want would be
git clone https://github.com/user/repository --depth 1 --branch=master ~/dir-name
. This will only copy the master branch, it will copy as little extra information as possible, and it will store it in ~/dir-name
.tjespetjespe
This will clone the files into new directory it creates:
LinuxSecurityFreakLinuxSecurityFreak
Let's start with the bash function I had handy for my own personal use:
You want the file to always be called master.zip and always be downloaded into your home directory, so:
However, there are a few things for you to consider:
1) My original script will give you a unique download zip file name for each download, based upon the name of the github repository, which is generally what most people really want instead of everything being called
master
and having to manually rename them afterwards for uniqueness. In that version of the script, you can use the value of $out_file to uniquely name the root directory unzipped tree.2) If you really do want all downloaded
zip
files to be named ~/master.zip
, do you want to delete each after they have been unzipped?3) Since you seem to always want everything put in directory
~/myAddons
, why not perform all the operations there, and save yourself the need to move the unzipped directory?user1404316user1404316
Not the answer you're looking for? Browse other questions tagged gitwget or ask your own question.
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:
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:
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:
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:
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:
![How to download from github android How to download from github android](/uploads/1/2/3/9/123951122/214223677.jpg)
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.