Downloading Stuff from GitHub in Linux Command Line

This started as a message reply to @4dandl4 , and was redirected to a topic by @Abhishek on my request.
The original question was…“How to get software from Github?”

  1. Simple case… download one file
    You can do this in the browser.
    Navigate to the github site
    Unix/grub at main · nevillejackson/Unix · GitHub
    If you wanted the file makeusb.pdf
    click on it
    it will display, and there is a download button.

  2. General case… download a whole repository
    Find out the name of the repository by browsing Github
    The quickemu project is at
    Quickemu Project · GitHub
    It has 3 repositories… quickemu, quickgui, quickemu-icons
    Say you want quickemu
    click on the quickemu repository and get its address
    GitHub - quickemu-project/quickemu: Quickly create and run optimised Windows, macOS and Linux desktop virtual machines.
    You will see a whole structure of directories and files

In your computer you need to have git installed
apt-get install git
and you need to give git some info

 git config --global "Neville Jackson"  your name of course
 git config --global youremailaddress
 git config --global core.editor vi
 git config --global true

Then make a directory to download into, and cd into it

$ mkdir quickemu
$ cd quickemu

Then initialize an empty git repository in your directory

$ git init
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint: 	git config --global init.defaultBranch <name>
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint: 	git branch -m <name>
Initialized empty Git repository in /common/quickemu/.git/

Then issue a git pull command

$ git pull
hint: Pulling without specifying how to reconcile divergent branches is
hint: discouraged. You can squelch this message by running one of the following
hint: commands sometime before your next pull:
hint:   git config pull.rebase false  # merge (the default strategy)
hint:   git config pull.rebase true   # rebase
hint:   git config pull.ff only       # fast-forward only
hint: You can replace "git config" with "git config --global" to set a default
hint: preference for all repositories. You can also pass --rebase, --no-rebase,
hint: or --ff-only on the command line to override the configured default per
hint: invocation.
remote: Enumerating objects: 3475, done.
remote: Counting objects: 100% (1465/1465), done.
remote: Compressing objects: 100% (66/66), done.
remote: Total 3475 (delta 1430), reused 1424 (delta 1399), pack-reused 2010
Receiving objects: 100% (3475/3475), 1.30 MiB | 1.61 MiB/s, done.
Resolving deltas: 100% (2304/2304), done.
 * branch            HEAD       -> FETCH_HEAD

Thats all, it is downloaded.

$ ls
build-docs  docs  LICENSE  macrecovery  quickemu  quickget  windowskey

You have a complete copy of the entire repo in a git controlled directory in your computer.
A git controlled directory is nothing special, it just contains a .git directory and a few other files

$ ls -a
.           docs           .github      LICENSE      quickget
..          .editorconfig  .gitignore   macrecovery
build-docs  .git           .gitmodules  quickemu     windowskey

Dont be confused by my MX prompt


it takes 2 lines. Not the usual one line prompt.

There is more to git than that. It is used to keep versions of files , for example while making changes in writing a program. It is used by the Linux kernel team. You can add file versions to git and it remembers them, so that you can roll back to any previous version of a file. No need to keep multiple copies of file versions.
As well as pull, you can push stuff into a remote repository … you have to own the repository to do that, you cant write on someone else’s repo,… but you can read anyone’s repo… that is the idea behind Gitub, it is FOSS unless you pay to make a private repo.

I think , if you agree , we might make this message a public topic.?

1 Like

By all means, git is one those mysterious Linux thing that all Linux users should learn. What is the downside of using git instead of just using a PPA?

It depends on what the software is.
If it is just a shell script, or python, not much different, you just want a copy of the script, and you can install it anywhere or just run it in your home directory.
If it is code that has to be compiled, the ppa will give you a precompiled binary, the Github download will give you the source code, and you will, have to compile it yourself.

So Github is really for programmers. It stores code. In theory that is all it does, but in practice people put other things there. I use it for tex documents, for example.
It is just a place for git repositories.

Git is a much bigger thing. It is a quite sophisticated version control system.
Version control has a long history. Some OS’s allowed version numbers on individual files… like DEC VMS. Linux does not do that… you can do it by hand just by putting numbers in the filenames. Git and other version control systems dont modify file names, they keep track of all the changes to a file, so you can wind back… just like timeshift only on individual files.
The tracking info is all in that .git directory., so when you back up it gets saved along with the files.

I dont know how to shift this to public. Will have to ask


Then maybe you could share some info on something else!!! Let’s take Gentoo and all the packages that make up Gentoo. Is someone or some corp being paid too write the code or is it strictly on a voluntary basis, surely money is being made. Would a person writing code need a degree in computer science?

That is it. All FOSS code is free… freely written, free to use.
All volunteered because people are fed up with inaccessible private code, that can not be maintained.
You dont need a degree to write code. Kids can do it.