Skip to content

Pull Request Simulation

Medium ~30 min

What you'll build

A local simulation of the pull request workflow using a bare remote as the 'upstream' repo. You will play both the contributor and the maintainer roles.

Goals

  • Simulate forking and cloning a project
  • Create a feature branch with changes
  • Push the branch and simulate a PR review
  • Address review feedback with additional commits
  • Merge the feature and clean up the branch

Prerequisites

  • git branch, merge, push, pull (Remote Collaboration Simulation)

Steps

  1. 1

    Set up the upstream repository

    Create a bare repo to act as the upstream project (like a GitHub repo you want to contribute to). Add an initial project.

    Code
    mkdir pr-simulation
    cd pr-simulation
    git init --bare upstream.git
    git clone upstream.git maintainer
    cd maintainer
    echo "# Contributable Project" > README.md
    echo "console.log('app')" > app.js
    git add .
    git commit -m "Initial project"
    git push origin main

    Expected result

    An upstream repo with an initial project, cloned as maintainer.

  2. 2

    Contributor clones and creates a feature branch

    As a contributor, clone the upstream, create a feature branch, and make a change. This simulates the start of a contribution.

    Code
    cd ../
    git clone upstream.git contributor
    cd contributor
    git checkout -b feature/add-tests
    echo "// test: app runs" > app.test.js
    git add .
    git commit -m "Add test for app.js"

    Expected result

    Contributor has a feature branch with a new test file.

  3. 3

    Contributor pushes the feature branch

    Push the feature branch to the remote. On GitHub, this is when you would open a pull request. The branch is now visible to the maintainer.

    Code
    git push -u origin feature/add-tests

    Expected result

    The feature branch is pushed to the remote.

  4. 4

    Maintainer reviews and requests a change

    The maintainer fetches the feature branch, reviews it, and requests a change (e.g., add a description to the test). This simulates PR review feedback.

    Code
    cd ../maintainer
    git fetch origin
    git checkout feature/add-tests
    cat app.test.js  # review the test
    # Request: add a description comment

    Expected result

    Maintainer has reviewed the feature branch and requested a change.

  5. 5

    Contributor addresses feedback and pushes again

    Back as the contributor, address the review feedback by adding a description, commit, and push. The PR is automatically updated.

    Code
    cd ../contributor
    echo "// Test: verifies that app.js runs and logs 'app'" > app.test.js
    echo "// test: app runs" >> app.test.js
    git commit -am "Add test description per review"
    git push origin feature/add-tests

    Expected result

    The feature branch is updated with the review feedback.

  6. 6

    Maintainer merges the PR and cleans up

    The maintainer fetches the updated branch, merges it into main, pushes, and deletes the feature branch. The contribution is complete.

    Code
    cd ../maintainer
    git checkout main
    git fetch origin
    git merge origin/feature/add-tests --no-ff -m "Merge feature/add-tests: add app test with description"
    git push origin main
    # Clean up the feature branch
    git push origin --delete feature/add-tests
    git log --oneline

    Expected result

    main has the feature merged; the feature branch is deleted from remote.

Try it yourself

What you learned

You simulated the complete pull request lifecycle: fork, branch, push, review, feedback, update, merge, cleanup. This is the exact workflow used by every open-source contributor and every team using GitHub.

Related Resources

Related Lessons

Related Cheatsheets

Look up unfamiliar terms

A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.

View glossary

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to topic