A step-by-step guide for contributing to GDG on Campus PUP projects using Git and GitHub. Follow this workflow for all your contributions.
Before you start, make sure you have:
- Git installed on your machine
- A GitHub account
- The repository URL
This guide covers the essential Git and GitHub collaborative workflow, progressing from setup to submitting contributions:
- Collaborative Workflow: Fork and Clone
- Understanding Branches
- Staging and Committing Changes
- Commits as Communication
- Writing Clear and Meaningful Commit Messages
- Best Practices for Commit Frequency
- Pull Requests
Let's break down each topic.
Purpose: Set up your own copy of the project so you can contribute without affecting the main repository.
A fork is your own copy of someone else's repository. When contributing to a shared project, you fork the repository, make your changes, and then propose merging them back via a Pull Request.
- Safe collaboration: You work on your own copy without affecting the main project
- Proper permissions: You can only push to your own fork
- Clear workflow: Pull Requests provide a formal review process
- Community standard: This is how open-source collaboration works
- Go to the main repository on GitHub
- Click the Fork button (top-right corner)
- GitHub creates a copy under your account
Clone your forked repository:
git clone https://github.com/YOUR-USERNAME/gh-and-git-guide.git
cd gh-and-git-guideTo keep your fork updated with the original repository:
git remote add upstream https://github.com/gdg-pup-webdev-team/gh-and-git-guide.gitVerify your remotes:
git remote -vYou should see:
origin→ your fork (where you push)upstream→ original repository (where you pull from)
Before creating a feature branch, update your local copy:
git fetch upstream
git checkout dev
git merge upstream/dev
git push origin devA branch is a separate line of development. Think of it like creating a parallel universe where you can work on your feature without affecting the main project.
| Branch | Purpose | Example |
|---|---|---|
| main | Production-ready code, stable releases | Main branch for deployment |
| dev | Development branch, testing ground | Staging before main |
| feature | New features and improvements | feature/add-personal-page |
| bugfix | Bug fixes | bugfix/fix-form-validation |
Create a new branch:
git checkout -b feature/feature-nameSwitch to an existing branch:
git checkout feature-nameList all branches:
git branch# Always start from dev
git checkout dev
git pull origin dev
# Create your feature branch
git checkout -b feature/add-personal-page
# Make your changes, commit, and push
git add .
git commit -m "feat(profile): add personal page template"
git push origin feature/add-personal-pageFirst, see which files have been modified:
git statusThis will show:
- Files you've modified (in red)
- Files you've staged for commit (in green)
To see the actual changes in your files:
git diffStage all changes:
git add .Stage a specific file:
git add <file-name>Once staged, create a commit with a meaningful message:
git commit -m "<type>(<scope>): <description>"A commit is not just a code change—it's a message to your team. Each commit tells a story about what changed and why.
Think of commits as:
- A record of progress
- A communication tool for your team
- A snapshot of your work at a point in time
- A way to track the history of your project
Good commits make it easier for others to understand your work and for you to debug issues in the future.
We follow Conventional Commits:
<type>(<scope>): <description>
| Type | Description | Example |
|---|---|---|
| feat | A new feature | feat(profile): add user profile page |
| fix | A bug fix | fix(nav): fix broken mobile menu |
| docs | Documentation changes | docs(readme): update setup guide |
| style | Code style changes (formatting, etc.) | style(css): reformat spacing |
| refactor | Code changes that neither fix a bug nor add a feature | refactor(api): simplify logic |
| test | Adding or modifying tests | test(auth): add login tests |
| chore | Maintenance and other minor tasks | chore(deps): update packages |
✅ DO:
- Use present tense: "Add feature" not "Added feature"
- Be specific about what changed
- Keep it concise but descriptive
❌ DON'T:
- Use vague messages like "update", "fix", "work"
- Write in past tense
- Make the message too long
Examples:
git commit -m "feat(profile): add user profile page with bio"
git commit -m "fix(navbar): resolve mobile menu alignment"
git commit -m "docs(readme): update installation instructions"- Easier to debug: Smaller changes are easier to trace if something breaks
- Better history: Your team can understand the progression of your work
- Easier to review: Small commits are easier to review in pull requests
- Simpler merging: Frequent commits reduce merge conflicts
Commit when:
- You complete a logical piece of work
- You fix a bug
- You finish a new feature
- You've made a meaningful change
Not every keystroke! Aim for commits that tell a story.
# Make a small change
# Test it locally
git add .
git commit -m "feat(profile): add name field validation"
# Make another related change
# Test it
git add .
git commit -m "feat(profile): add email field to form"
# Fix a styling issue
git add .
git commit -m "style(profile): improve form spacing"A Pull Request (PR) is a way to propose changes to a project. It allows others to review your code, suggest improvements, and eventually merge your work into the main project.
Think of it as saying: "Hey team, I've made some changes. Please review them and let me know if they're good to merge."
- Code Review: Team members can review and improve your code
- Discussion: Collaborate and discuss changes before merging
- Quality Control: Catch bugs and issues before they reach production
- Documentation: PRs create a record of why changes were made
Step 1: Push Your Branch to YOUR Fork
git push origin feature/your-feature-nameStep 2: Create PR on GitHub
- Go to the original repository (not your fork)
- You'll see a banner suggesting "Compare & pull request" — click it
- If you don't see it, go to the Pull Requests tab and click New Pull Request
- Click compare across forks
- Select:
- Base repository: original repo, branch
dev(ormain) - Head repository: your fork, branch
feature/your-feature-name
- Base repository: original repo, branch
- Add a clear title and description
- Click Create Pull Request
Title:
<type>(<scope>): <short description>
Description:
## What Changed?
Brief explanation of what was added or changed.
## Screenshots (if applicable)
Add relevant screenshots or gifs.
## Checklist
- [ ] Code tested locally
- [ ] Follows project conventions
- [ ] No breaking changesFor contributors:
- Wait for team members to review your PR
- Respond to feedback and make requested changes
- Once approved, a maintainer will merge your PR
For maintainers:
- Review the code changes
- Leave constructive comments if needed
- Once approved, merge the PR
- Delete the branch after merging
Apply what you've learned by creating a personal page in the workshop repository and submitting a pull request.
-
Fork the repository
- Go to https://github.com/gdg-pup-webdev-team/gh-and-git-guide.git
- Click the Fork button (top-right corner)
- GitHub creates a copy under your account
-
Clone YOUR fork (not the original)
git clone https://github.com/YOUR-USERNAME/gh-and-git-guide.git cd gh-and-git-guide -
Add the upstream remote
git remote add upstream https://github.com/gdg-pup-webdev-team/gh-and-git-guide.git
-
Update your fork from upstream
git fetch upstream git checkout dev git merge upstream/dev git push origin dev
-
Create a feature branch
git checkout -b feature/add-personal-page-your-name
-
Add your personal page
- Copy the personal page template from the
templates/personal-page-template.mdfile - Create a new file:
personal-pages/your-name.md - Fill in your information (name, bio, interests, GitHub profile, etc.)
- Copy the personal page template from the
-
Commit your changes
git add personal-pages/your-name.md git commit -m "feat(profile): add personal page for [Your Name]" -
Push to YOUR fork
git push origin feature/add-personal-page-your-name
-
Create a Pull Request
- Go to the original repository
- Click Compare & pull request
- Select: base repo
dev← compare your fork'sfeature/add-personal-page-your-name - Add a title:
feat(profile): add personal page for [Your Name] - Add a description explaining who you are
- Click Create Pull Request
-
Wait for Review
- A team member will review your PR
- Make any requested changes
- Once approved, your PR will be merged!
- Always fork first — this lets you create PRs without write permissions
- Keep your personal page concise and professional
- Use the template provided to ensure consistency
- Review your changes locally before pushing
- Be responsive to feedback during the review process
Here's a quick reference for commands you'll use often:
| Command | Purpose |
|---|---|
git status |
Check the status of your files |
git add <file> |
Stage a specific file |
git add . |
Stage all changes |
git commit -m "message" |
Commit staged changes |
git push origin <branch> |
Push changes to your fork |
git pull origin dev |
Pull latest changes from your fork |
git fetch upstream |
Fetch updates from original repository |
git merge upstream/dev |
Merge upstream changes into local branch |
git checkout -b <branch> |
Create and switch to a new branch |
git checkout <branch> |
Switch to an existing branch |
git branch |
List all branches |
git log |
View commit history |
git diff |
See changes before staging |
Ready to contribute to GDG on Campus PUP projects? Start by forking, cloning your fork, and submitting your first pull request today!