By the end of this laboratory session, students will be able to:
- Clone a shared GitHub repository.
- Create and switch to a branch from
main
before making changes. - Add and modify files.
- Stage, commit, and push changes to GitHub.
- Merge changes back into
main
.
- Git must be installed on the workstation (
git --version
to verify). - Students must have an active GitHub account.
- A text editor or IDE (Visual Studio Code recommended).
Each student must configure their Git identity for this repository only (not global):
git config user.name "Your Name"
git config user.email "your.email@example.com"
Verify your configuration:
git config --list --local
If you want Git to remember your credentials securely, enable the credential manager:
git config credential.helper manager
- On macOS, you may use the macOS Keychain:
git config credential.helper osxkeychain
- On Windows, you may use:
git config credential.helper manager-core
This ensures Git will prompt you for credentials only once per repository and store them securely.
Each student will clone the class repository:
cd path/to/your/workspace
git clone https://github.com/2026-DCIT26/LabActivity1.git
cd LabActivity1
Each student must create a branch named using this format:
feature/<your-student-number>
Example:
git checkout -b feature/201811394
This ensures that every student works on their own branch without affecting
main
.
Create a file named notes.txt
:
echo "This is my notes file." > notes.txt
Stage and commit:
git add notes.txt
git commit -m "Add notes.txt file with initial content"
Push the branch to GitHub:
git push origin feature/201811394
Edit README.md
using an editor or terminal:
echo "\n## Additional Notes\nThis is an update." >> README.md
Stage, commit, and push:
git add README.md
git commit -m "Update README with additional notes"
git push origin feature/201811394
Students should verify changes on GitHub in their own branch.
After everyone has pushed their branch, the instructor may demonstrate merging one branch into main
.
git checkout main
git merge feature/201811394
git push origin main
Students must:
- Refresh the repository page on GitHub.
- Confirm that their branch (e.g.,
feature/201811394
) exists. - Check that their commits and files appear under their branch.
Action | Command |
---|---|
Configure identity | git config user.name / git config user.email |
Credential manager | git config credential.helper manager (or osxkeychain /manager-core ) |
Clone repository | git clone https://github.com/2026-DCIT26/LabActivity1.git |
Create branch | git checkout -b feature/201811394 |
Switch branch | git checkout <branch> |
Stage file(s) | git add <filename> |
Commit changes | git commit -m "message" |
Push to branch | git push origin feature/201811394 |
Merge branch | git merge feature/201811394 |
Check status | git status |
View changes | git diff |
Each student must:
- Submit a screenshot of their terminal showing
git log
from their personal branch. - Provide a link to their branch in the repository.
- Ensure that
notes.txt
and README updates are visible in their branch on GitHub. \n## Additional Notes\nThis is an update. \n## Additional Notes\nThis is an update. \n## Additional Notes\nThis is an update.