SDPT Lab 1
Lab 1: Foundation of Process - Git and GitLab Basics
Introduction
Welcome to the first lab of Software Development Process and Testing (SDPT). In our lecture, we discussed why treating software like a physical breadboard leads to failure in complex systems. We introduced the Software Development Life Cycle (SDLC), Issue Tracking, and the underlying graph model of Git.
Today, we put theory into practice. By the end of this 2-hour lab, you will have:
- Configured secure SSH authentication with your GitLab server.
- Created a project repository and your first tracked Issue.
- Configured Git on your local machine.
- Moved a C++ source file through the Three States of Git.
- Prevented binary files from entering your repository using
.gitignore. - Pushed your local history to the remote GitLab server to automatically close your Issue.
Note: Do not rush. The goal is to understand where your files are in the Git graph at any given moment. Run git status frequently!
Part 1: Secure Authentication (SSH Keys)
Modern code repositories do not allow you to push code using your standard web password. We must set up a secure cryptographic key pair.
1. Generate an SSH Key Pair
Open your terminal (Linux/macOS) or Git Bash (Windows) and type:
ssh-keygen -t ed25519 -C "your.university.email@stud.####.upb.ro"
- Press Enter to accept the default file location.
- Press Enter twice to skip creating a passphrase (for the sake of this lab environment).
This generated two files: a private key (never share this!) and a public key.
2. Add the Public Key to GitLab
Display your public key in the terminal and copy the output exactly:
cat ~/.ssh/id_ed25519.pub
- Log into your university GitLab account in your browser.
- Click your profile avatar (top right) -> Edit profile -> SSH Keys (on the left sidebar).
- Click Add new key. Paste your copied key into the "Key" box. Title it "My Lab Laptop" and click Add key.
Part 2: Setting Up the Remote (GitLab)
Before we write code, we document our work.
1. Create a New Repository
- Go to the GitLab homepage. Click New Project -> Create blank project.
- Project Name:
sdpt-rfid-access - Visibility Level: Private (or Internal).
- Important: Uncheck "Initialize repository with a README". We want an entirely empty repository.
- Click Create project.
2. Create Your First Issue
- On the left sidebar of your new project, navigate to Plan -> Issues.
- Click New issue.
- Title:
Create initial RFID reader driver skeleton - Description:
Need a basic main.cpp file that will eventually hold the SPI communication logic for the RFID module. - Click Create issue. Take note of the Issue Number (e.g.,
#1).
Part 3: Initializing the Local Environment
1. Configure Your Identity
Git embeds your name and email into every commit permanently. Run these once:
git config --global user.name "Your First and Last Name"
git config --global user.email "your.university.email@domain.edu"
2. Create Your Local Workspace
Create a folder for your project and initialize it as a Git repository.
mkdir sdpt-rfid-access
cd sdpt-rfid-access
git init
Part 4: Ignoring the Noise (.gitignore)
In C/C++, compiling creates binary files (like .o, .out, or .exe). We never track compiled binaries in Git—we only track human-readable source code!
Let's tell Git to permanently ignore build files.
Create a file named exactly .gitignore:
touch .gitignore
Open it in your editor and add these lines:
# Ignore compiled binaries
*.o
*.out
*.exe
# Ignore IDE folders
.vscode/
.idea/
Save the file. Let's stage and commit our configuration:
git add .gitignore
git commit -m "Add .gitignore for C++ project"
Part 5: The Three States in Practice
Let's move our actual source code through the Working Directory, Staging Area, and Repository.
1. The Working Directory
Create your C++ file:
touch main.cpp
Open main.cpp and add a basic skeleton:
#include <iostream>
int main() {
std::cout << "RFID Access Control System Initialized" << std::endl;
return 0;
}
Check your radar:
git status
Notice main.cpp is red. It is Untracked.
2. The Staging Area (Index)
Tell Git to include this in the next snapshot.
git add main.cpp
git status
It is now green. It is Staged.
3. Time Travel and Diffs
Wait! Before committing, what exactly did we just stage? It's good practice to review your code.
git diff --staged
This shows you the exact lines of C++ you are about to commit. Press q to exit the diff view if it pauses.
4. The Repository (Commit)
Save the snapshot permanently.
git commit -m "Add initial RFID system skeleton"
git status
Part 6: Connecting Local to Remote and Closing Issues
Your code is safe locally, but the "Bus Factor" is still 1. We must push to GitLab using the SSH key we created earlier.
1. Link the Remote Server
Go back to your GitLab project page. Under "Push an existing Git repository", click the SSH button (not HTTPS) and copy the git remote add origin... command. It will look like this:
git remote add origin git@gitlab.com:your-username/sdpt-rfid-access.git
Paste and run that in your terminal.
2. Push and Close the Issue
Let's make one final change to fulfill our Issue requirement and close it automatically.
Open main.cpp and add a comment:
// TODO: Implement SPI communication with RC522 module
Stage and commit this change, using the special keyword (Closes #1) in your commit message:
git add main.cpp
git commit -m "Add SPI TODO comment. Closes #1"
Push your local graph to the remote server:
git push -u origin main
(Note: If Git complains about 'main', try git push -u origin master, or ask your professor how to rename your default branch).
When prompted "Are you sure you want to continue connecting?", type yes and press Enter.
3. Verify the Magic
Refresh your GitLab project page in your browser:
- Your
main.cppand.gitignorefiles are visible! - Go to Plan -> Issues. Notice that Issue #1 is now automatically marked as Closed.
Lab Deliverable
To receive full credit for this week's lab, call the professor or teaching assistant over to your workstation and demonstrate:
- Your GitLab repository showing the code and the
.gitignorefile. - Your GitLab Issue board showing Issue #1 as Closed.
- Your terminal showing the output of the
git log --onelinecommand, displaying your three commits.