Git and Github for the mediocre

Robert Crowther Apr 2025

I assume you know what Git and Github are.

Git usage reminders

Briefly,

Update a repository

git add .
git commit
git push origin main

Download/clone a repository

Copy the SSH address from the repository on Github then,

git clone ssh/uri/address

Update from Github

git pull

Can throw errors if there are uncommitted changes locally. Sometimes easier to delete everything and download a new clone (see above).

Git setup

If you don’t have it or it’s new computer, install (some fancy Linux distributions have Git pre‐installed). Packaging is ok.

Then see any settings available,

git config --list --show-origin

In a terminal, do this,

git config --global user.name "John Doe"
git config --global user.email johndoe@example.com
git config --global core.editor emacs

If you have a Github account, answers to first two questions should be your Github details. I usually set ‘editor’ to ‘nano’ which is available on Debian and not annoying—but your choice.

For more, look at Git instructions for first‐time users.

New Github account

To download from Github, you don’t need an account. If that’s all you’re doing, don’t bother. Otherwise you need a Github account.

Be careful in setup. You’ll be using many of the details again for connecting, authenticating, searching code etc. Don’t crash through registration with any old password, hit‐and‐hope tactics, whatever security answers and so forth.

To send info to Github…

If this is not enough, see the in‐depth info on Github authentication.

Get an authenticator app on your phone, then register it

Authenticator apps are also called TOTP (‘time‐based one‐time password’) apps. Most do not work across the major platforms. Time of writing, here are some,

or a hardware solution like the expensive,

Go to,

[Github Avatar] > Settings > Password and authentication > Enable two‐factor authentication

Scan the QR code onto you phone, then you’ll get a code to type back into Github (to confirm the other way).

Or look at Github instructions on how to set up two‐factor authentication. That also provides information on registering a TOPT app manually, or using SMS.

The recovery codes

Will be supplied as soon as you enable an authorisation method Github approves of. You download them as a text file. Save these in a secure place, or places. Without them, you can be locked out of a Github account permanently.

Setup an SSH channel

To send info to a Github account you need an secure connection (ignore misdirection about HTTPS). Github will not generate keys… you generate keys then register them with Gihub.

Setup SSH

For more info, see the article on SSH setup.

Make a SSH key (the ‐t option is the encryption type required by Github, don’t change it),

ssh-keygen -t ed25519 -C "your_email@example.com"

Accept the default location (usually). Then you’ll be asked for a passphrase. You don’t need to put one in though I’m bound to tell you Github recommend you do.

On Linux, the private key will be in,

~/.ssh/id_ed25519

If you’re using a passphrase, you can add this to an agent. If you need to.

Copy the contents of the public key at,

~/.ssh/ed_id25528.pub

into the Github website at,

[Github Avatar] > Settings > SSH Keys > ‘SSH and GPG Keys’ > ‘New SSH Key’

Give it a name to identify the computer used, like “My yellow computer”.

Should be working now. If there is a problem, it may be local permissions,

.ssh directory

700

private keys

600

public keys

644.

But in this case, probably not.

Or use Github instructions on SSH setup

Test

If you have an existing Github account try a clone then push. It won’t do anything, but will tell you if you connected ok,

git clone xxxx
cd [into new clone]
git push origin main

You may be challenged for passphrases/passwords. First time, this may churn about, because the connection is being approved and maybe loaded into password keyrings. If it’s working, it will reply,

Account is up to date

Note: Github clones store their source ‘hosts/filepaths/usernames’ someplace, so no need to mess with the SSH ‘config’ file, or anything like that

That’s it

I hope. For you, my wishes.