3. Collaborating on GitHub

Capstone: Full Team & Open-Source Workflow

Practice an end-to-end professional Git & GitHub workflow: clone, branch, commit cleanly, simulate and resolve a merge conflict, and prepare a release-ready Pull Request.

3 min readUpdated 2026-11-29
In This Lesson
  • Execute a complete branch, commit, diff, and merge workflow end to end
  • Verify staged files and diffs before pushing to GitHub
  • Follow a production-ready pre-PR engineering checklist

Reading Git commands one by one is useful, but real confidence comes from chaining them together smoothly from an empty folder all the way to a finished, clean merge. Let's walk through a realistic end-to-end engineering workflow in a temporary practice directory on your own machine.

Starting a Clean Sandbox Repository

Begin by creating an isolated practice folder, initializing main, and recording a starting README.md commit so main has a solid anchor point:

bash
mkdir git-capstone && cd git-capstone
git init -b main

echo "# Team Handbook" > README.md
git add README.md
git commit -m "Initialize Team Handbook repository"

Just like on a real engineering team, once main is initialized, we avoid committing new features directly to it.

Building on an Isolated Feature Branch

Next, open a descriptive feature branch (feat/onboarding-checklist), add a setup item in one focused commit, and add a testing reminder in a second focused commit:

bash
git switch -c feat/onboarding-checklist

echo "- Install Git and Python" > checklist.md
git add checklist.md
git commit -m "Add initial developer setup checklist"

echo "- Run test suite before opening PR" >> checklist.md
git add checklist.md
git commit -m "Add pre-PR testing reminder"

Keeping commits small and focused—one logical change per commit—makes code reviews dramatically easier for your teammates.

Reviewing History, Merging, and Cleaning Up

Before bringing your feature back into main, inspect how the branch timeline looks and double-check the exact diff between main and your branch:

bash
git log --oneline --graph --all
git diff main..feat/onboarding-checklist

Once everything looks clean, switch back to main, merge your feature branch in, and delete the finished branch so your repository stays tidy:

bash
git switch main
git merge feat/onboarding-checklist
git branch -d feat/onboarding-checklist

Notice that -d safely confirms the branch's work is already merged before deleting the label—your commits remain safely preserved in main.

Syncing a Fork With upstream (Open-Source Workflow)

When contributing to an external open-source repo, you have two remotes:

  • origin — your personal fork on GitHub (where you push feature branches)
  • upstream — the original project repository (where maintainers merge PRs)
bash
# Link the original project once
git remote add upstream https://github.com/original-org/project.git

# Keep your local main in sync before starting a new PR
git switch main
git fetch upstream
git merge upstream/main
git push origin main
Verify Remotes Anytime

Run git remote -v whenever you aren't sure where origin and upstream point.

Pro Habit: Check Everything Before git push

Before opening any Pull Request on GitHub, senior engineers run through a quick mental verification so no secrets, leftover debug logs, or broken tests slip into review:

Pre-PR Engineering Checklist

0/5 done

You now have the exact terminal and Git workflow used by professional software teams every single day!