How to Use GitHub with SSH Keys

Week 3 of Configuration Management Systems course.

Course material:

Environment: VirtualBox VM running Debian 11 XFCE. VM has 4 GB of RAM and 40 GB of disk space.


Objective: Write this post using Markdown language.

All of my posts are written in Markdown. Source code for this post.


Objective: Create a local git repository. Repository name must include the word cat. Set your git name and email. Demonstrate making changes to your repository and viewing git logs.

I created a new folder called tiny-cat.

$ mkdir tiny-cat

I moved into the new folder and initialized a new git repository.

$ cd tiny-cat
$ git init

I set my git name and email. (Setting your username in git)

$ git config --global
Tuomas Valkamo
$ git config --global

I created a file called hello.txt and committed it to my repository.

$ touch hello.txt
$ git add .
$ git commit -m "Add hello.txt"

The -m flag lets me write the commit message in the same command.

I checked the git log. It showed the commit I made.

$ git log

git log


Objective: Make a dumb change to git, do not commit. Erase unwanted changes with git reset --hard. Note that this operation can’t be undone.

I created a new file called doh.txt.

$ touch doh.txt

I ran the git reset command but the file wasn’t deleted from the project directory.

$ git reset --hard

After reading the documentation I realized that the changes have to be added to the git index (source: man git-reset, man git-add). Only after that can the changes be reset.

$ git add .
$ git reset --hard

git reset


Objective: Create a repository to GitHub. The name must include the word car.

I created a new repository called red-car. I added a, and LICENCE (GNU GPL v3) files.

github new repository


Objective: Clone your repo from GitHub to your machine. Make changes and push them to GitHub. Show the changes in the web interface.

I cloned the project to my user directory using SSH.

$ cd
$ git clone

Written from memory since I had already done this step:

I generated a new SSH key.

$ ssh-keygen

I copied my SSH public key from /home/tuomas/.ssh/ I added a new SSH key to GitHub in and pasted my public key there.

Continuing from here:

Inside the red-car repository, I created a new file called foobar.txt, added it to index, committed it, pulled the most recent version, and pushed the changes to GitHub.

$ touch foobar.txt
$ git add .
$ git commit -m "Add foobar.txt"
$ git pull
$ git push

github logs


Profile picture

Written by Tuomas Valkamo who is studying IT at Haaga-Helia University of Applied Sciences.

Check out my GitHub. or Connect with me.

© 2022 Tuomas Valkamo