Raspberry Pi_Eng_17.4.3 How to Download from Internet Using GitHub


Published Book on Amazon


All of IOT Starting with the Latest Raspberry Pi from Beginner to Advanced – Volume 1
All of IOT Starting with the Latest Raspberry Pi from Beginner to Advanced – Volume 2

출판된 한글판 도서


최신 라즈베리파이(Raspberry Pi)로 시작하는 사물인터넷(IOT)의 모든 것 – 초보에서 고급까지 (상)
최신 라즈베리파이(Raspberry Pi)로 시작하는 사물인터넷(IOT)의 모든 것 – 초보에서 고급까지 (하)

Original Book Contents


17.4.3  How to Download from Internet Using GitHub

 

Finally, there are programs that provide source program in the GitHub. GitHub provides the tool that allows developers to securely manage the source code of development program in the process of developing, deploying, and later managing open source programs and manage versions of subsequent modifications from development to post-management. The programs that are managed here are kept in the GitHub repository, and you can always download and use the source code for those who need it.

 

To download programs from GitHub, you first need to install the Git program. It is installed by default in the latest version of Raspbian so you do not need to do anything else. If it is not installed, install it as follows.

 

sudo apt-get install git

 

You can use the "git" command to download the program to install from GitHub.

 

[Command Format]

git  [command]   [option] 

 

[Command Overview]

   This downloads the specified file from the GitHub.

   User privilege          -- Normal user.

 

[Detail Description]

   Git URL supports ssh, git, http, https, ftp, ftps, and rsync protocols by default. The format used for each protocol is as follows:

    ssh       -- ssh://[user@]host.xz[:port]/path/to/repo.git/

    git        -- git://host.xz[:port]/path/to/repo.git/

    http[s]   -- http[s]://host.xz[:port]/path/to/repo.git/

    ftp[s]     -- ftp[s]://host.xz[:port]/path/to/repo.git/

    rsync    -- rsync://host.xz/path/to/repo.git/

   The downloaded program package is saved in the current working directory unless specified otherwise.

 

[Main command]

clean

Remove untracked files from the working tree.

clone

Clone a repository into a new directory.

à Used to download.

log

Show commit logs.

git-gc

Cleanup unnecessary files and optimize the local repository.

 

[Main Option]

--depth <depth>

Select a specific version of source

-C <path>

Run as if git was started in <path> instead of the current working directory.

-p, --paginate

 

Pipe all output into less (or if set, $PAGER) if standard output is a terminal. This overrides the pager.<cmd> configuration options (see the "Configuration Mechanism" section below).

 

[Used Example]

Next is how to download the <WiringPi> library package from GitHub. This example is done by specifying git-path which is GitHub's own path to the download file path.

 

pi@raspberrypi ~ $ git clone --depth 1 git://git.drogon.net/wiringPi

Cloning into 'wiringPi'...

remote: Counting objects: 167, done.

remote: Compressing objects: 100% (146/146), done.

remote: Total 167 (delta 79), reused 46 (delta 16)

Receiving objects: 100% (167/167), 156.26 KiB | 110 KiB/s, done.

Resolving deltas: 100% (79/79), done.

 

The following example is done by specifying the URL path to the download file path as shown below.

 

pi@raspberrypi ~ $ git clone --depth 1  https://github.com/WiringPi/WiringPi

Cloning into 'WiringPi'...

remote: Counting objects: 70, done.

remote: Compressing objects: 100% (50/50), done.

remote: Total 70 (delta 25), reused 59 (delta 19), pack-reused 0

Unpacking objects: 100% (70/70), done.

 

If you check the data in [File Manager] after downloading the program is completed, you can see that "WiringPi" directory is created as below and several files are downloaded inside.