Git & GitHub Fundamentals Part 2
Worksheet 2 โ Git & GitHub Collaborative Workflow | This workshop focuses on the social side of GitHub. You will learn how to contribute to projects you don't own by using the Fork and Pull Request workflow. This is the cornerstone of Open Source contribution and professional team development.
๐ค Worksheet 2 โ Git & GitHub: Open Source Contribution
๐ฏ Objective
By the end of this workshop, you will be able to:
- โ Fork a public repository to your own account
- โ Clone a remote repository to your local machine
- โ Create and manage Feature Branches
- โ Sync changes with the Original (Upstream) repository
- โ Create a Pull Request (PR) to contribute your work
๐ Prerequisites
- Completed Worksheet 1 โ Part 1
- GitHub account active
- Git configured on your local machine
๐ The Challenge: "Git Gud Quotes"
We will be contributing to a shared repository of developer quotes called gitgudquotes. Your task is to add your favorite programming quote to the collection.
Project Resources:
- Github Repository: https://github.com/alfhisa/gitgudquotes
- Live Version: https://gitgudquotes.vercel.app/
๐ Step-by-Step Guide
Part 1 โ Forking the Project
A Fork is a personal copy of someone else's project.
- Open https://github.com/alfhisa/gitgudquotes in your browser.
- Click the Fork button (top right).
- Ensure the owner is your username and click Create Fork.
Part 2 โ Cloning Your Fork
Now you need a local copy of your fork.
- On your fork's page, click Code and copy the HTTPS URL.
- Open your terminal and run:
git clone https://github.com/YOUR_USERNAME/gitgudquotes.git
cd gitgudquotes
Part 3 โ Branching for Safety
Never work directly on the main branch when contributing.
- Create a new branch named after your quote:
git checkout -b add-quote-yourname
Part 4 โ Making the Contribution
- Open the project in VS Code:
code .
- Open
quotes.jsonorREADME.md(check the repo instructions). - Add a new quote following the existing format:
{
"quote": "Talk is cheap. Show me the code.",
"author": "Linus Torvalds"
}
Part 5 โ Commit and Push
- Stage and commit your changes:
git add .
git commit -m "feat: add Linus Torvalds quote"
- Push your branch to GitHub:
git push origin add-quote-yourname
Part 6 โ The Pull Request (PR)
This is where the magic happens. You are asking the original owner to pull your changes.
- Go back to the original repository:
https://github.com/alfhisa/gitgudquotes. - You should see a yellow banner saying "Compare & pull request". Click it.
- Add a clear title (e.g.,
Update: Add Linus Torvalds quote) and a short description. - Click Create pull request.
๐ Final Challenge Check
- Your fork exists on your GitHub profile.
- You have a new branch in your fork.
- You have submitted a Pull Request to the original repo.
- Wait for the maintainer to review and merge!
๐ก Pro Tip: Syncing with Original
If the original repo changes while you are working, sync your fork:
git remote add upstream https://github.com/alfhisa/gitgudquotes.git
git fetch upstream
git merge upstream/main