Git and GitHub Setup¶
Git tracks changes in code and lab files. GitHub hosts repositories so students can clone course material, submit work, and practice professional version control.
This page follows the practical APT-based installation path from DigitalOcean's How To Install Git on Ubuntu.
1. Install Git¶
Verify:
2. Configure Git Identity¶
Use your real name or course-approved name:
Use main as the default branch name:
Set a simple terminal editor:
Review settings:
3. Create a Lab Workspace¶
Create a first file:
echo "# Practice Repository" > README.md
git status
git add README.md
git commit -m "Initial commit"
4. GitHub SSH Key Setup Optional¶
If you will push to GitHub by SSH, create or reuse an SSH key:
Copy the public key into GitHub:
Test:
Expected: GitHub greets your username. It may also say shell access is not provided; that is normal.
5. Basic Git Commands¶
| Task | Command |
|---|---|
| Check repository status | git status |
| See changes | git diff |
| Stage a file | git add FILE |
| Commit staged changes | git commit -m "Message" |
| Show commit history | git log --oneline --graph --decorate |
| Clone a repository | git clone URL |
| Pull new changes | git pull |
| Push local commits | git push |
6. Classroom Checkpoint¶
Record:
Troubleshooting¶
| Problem | Fix |
|---|---|
| Git asks for identity on commit | Run git config --global user.name and git config --global user.email. |
| GitHub rejects password authentication | Use SSH keys or a GitHub personal access token. |
fatal: not a git repository | Run the command inside a repository folder or initialize one with git init. |
Next Step¶
Continue to VS Code Remote SSH, or go directly to Docker Setup on Ubuntu Server.