Skip to content

Git & GitLab Onboarding: Working Safely on TechLit Computers

Your user home resets on logout. Use the persistent storage area at /srv/public/ for your keys and projects.


This phase takes about 10 minutes. You set up your GitLab account, add a persistent SSH key, and set your Git identity.

You need a GitLab account to identify your contributions.

  1. Register. Go to GitLab.com and create a free account.

  2. Join the group. Once your account is ready, request GitLab write access on WhatsApp. Provide your GitLab username. You will be added to the techlit-africa workspace.

To connect to GitLab without a password, we generate an SSH key. We store it in your persistent folder so it survives a logout.

# 1. Create the secure folder (Use your actual username instead of 'denis')
mkdir -p /srv/public/teachers/denis/guest/.ssh

# 2. Cd into your persistent guest directory
cd /srv/public/teachers/denis/guest

# 3. Generate the key
ssh-keygen -t ed25519 -f .ssh/id_ed25519 -C "denis@techlitafrica.org"

# 4. Link for GitLab Access (Removes need for -i flag)
ln -s /srv/public/teachers/denis/guest/.ssh/id_ed25519 /srv/guest/gitlab_ssh

Git needs to know who is making changes so that your name appears correctly in the project history.

# Set your name and email
git config --global user.name "Denis"
git config --global user.email "denis@techlitafrica.org"
git config --list

This phase takes about 15 minutes. You make a backup, check status, clone, and save work.

Before practicing Git commands, always make a local duplicate of your folder. This is your 100% safe “undo button” if a command gets confusing.

# 1. Navigate to your projects directory
cd /srv/public/teachers/denis/guest/projects

# 2. Duplicate your project folder before experimenting
cp -r websites websites_backup

Think of git status as the terminal user’s eyes. Run it before you add a file, after you stage it, and right before you commit. If you ever feel lost, git status is the first command you should type.

Pull the websites repository from GitLab into your persistent projects folder.

git clone git@gitlab.com:techlit-africa/websites.git
cd websites
ls

Git uses a holding zone to help you organize what you save.

  1. Modified: You have edited a file (e.g., src/main.js) but haven’t told Git to save it yet.
  2. Staged (git add): You have picked which changes you want to include in your next save. Think of this as putting files into a “to-be-saved” box.
  3. Committed (git commit): You have permanently saved the snapshot of your staged files to your local history.

We never edit the main branch directly. We use feature branches to keep our production code stable. This phase takes about 15 minutes. You create a feature branch, keep it current, push it, and open a Merge Request.

# 1. Start with the latest code
git switch main
git fetch origin
git pull origin main

# 2. Create your experimental branch
git switch -c feature/add_new_feature

If you haven’t worked on your feature branch for a few days, rebase it to include the latest team changes.

git switch main
git pull origin main
git switch feature/add_new_feature
git rebase main

Once you have committed your work locally, send it to GitLab to share it with the team.

git push origin feature/add_new_feature
flowchart TD
    LM["Local main"] --> FB["feature/add_new_feature"]
    FB -->|"git push origin"| RM["origin/main"]
    RM -->|"Open Merge Request"| MR["Merge Request"]
    MR -->|"Merge into main"| RM
    RM -->|"git pull"| LM

The feature branch starts from local main and merges back through a Merge Request.

gitGraph
    commit id: "start"
    commit id: "clone"
    branch feature/AddGuide
    commit id: "edit"
    commit id: "test"
    checkout main
    merge feature/AddGuide

The diagram shows the commit order on main and the feature branch.


  • If a rebase or merge becomes confusing, run git rebase --abort.
  • Always check your .gitignore to ensure temporary files are not tracked.
  • Anything left in ~/ or /home/guestdisappears forever on logout. Always verify your path with pwd.

Run git rebase --abort if a rebase or merge feels wrong. Check your path with pwd.