Workshop
Git & GitHub Fundamentals Part 1
Worksheet 1 โ Git & GitHub Fundamentals | This guide is designed to help you understand the core concepts of version control using Git and how to collaborate using GitHub. You will learn how to track changes, manage branches, and sync your work between your local computer and a remote repository.
๐ Worksheet 1 โ Git & GitHub Fundamentals (Local โ Remote)
๐ฏ Objective
By the end of this workshop, you will be able to:
- โ Initialize a Git repository
- โ Track changes using commit
- โ Connect local work to GitHub
- โ Push and pull changes effectively
- โ Work with branches for safe development
- โ Handle merges and simple conflicts
๐ Prerequisites
- Git installed on your machine
- GitHub account created
- VS Code (or your preferred text editor)
- Basic terminal/command line familiarity
๐ Step-by-Step Guide
Part 0 โ Setup
Check Git installation
git --version
Configure identity
git config --global user.name "Your Name"
git config --global user.email "your_email@example.com"
Part 1 โ Create Local Repository
Create project folder
mkdir latihan-github
cd latihan-github
Initialize Git
git init
Open project in VS Code
code .
Part 2 โ First Commit
Create file in VS Code
Create:
README.md
Isi:
# Latihan GitHub
Ini adalah repository latihan Git dan GitHub.
Check status
git status
Add and commit
git add .
git commit -m "Add initial README"
Part 3 โ Modify File
Edit README.md di VS Code
Tambahkan:
## Deskripsi
Repository ini digunakan untuk belajar Git.
Check changes
git status
git diff
Commit changes
git add .
git commit -m "Update README description"
Part 4 โ Connect to GitHub
Create repository on GitHub
- Name: latihan-github
- Visibility: Public
- Do NOT initialize with README
Connect local to GitHub
git remote add origin https://github.com/USERNAME/latihan-github.git
Rename branch
git branch -M main
Push
git push -u origin main
Part 5 โ Add New File
Create file in VS Code
Create:
profile.txt
Isi:
Nama: (isi nama)
Kelas: (isi kelas)
Hobi: (isi hobi)
Commit and push
git add .
git commit -m "Add student profile"
git push
Part 6 โ Branching
Create new branch
git checkout -b feature/update-profile
Edit file in VS Code
Tambahkan:
Skill: Git dasar
Commit
git add .
git commit -m "Add skill to profile"
Switch back to main
git checkout main
Merge branch
git merge feature/update-profile
git push
Part 7 โ Pull from GitHub
Edit file on GitHub (manual step)
- Open README.md
- Click edit
- Add:
Update from GitHub web
Pull changes locally
git pull origin main
Expected Output
- Repository exists on GitHub
- Multiple commits visible
- Branch created and merged
- Local repo synced with remote
๐ Finished?
If you have completed all the steps above and want a bigger challenge, proceed to the next part where you will learn how to contribute to an open-source project!