Bird
Raised Fist0
Gitdevops~5 mins

Fork and pull request workflow in Git - Cheat Sheet & Quick Revision

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is a fork in GitHub?
A fork is a personal copy of someone else's repository. It lets you freely make changes without affecting the original project.
Click to reveal answer
beginner
What is a pull request?
A pull request is a way to ask the original project owner to review and merge your changes from your fork into their repository.
Click to reveal answer
intermediate
Why do we use forks and pull requests instead of pushing directly to the main repository?
Forks and pull requests keep the main project safe. They let others review your changes before adding them, preventing mistakes or unwanted code.
Click to reveal answer
beginner
What is the typical first step after forking a repository?
Clone your fork to your local computer so you can work on the code using Git commands.
Click to reveal answer
beginner
What happens after you create a pull request?
The project maintainers review your changes. They may ask for improvements or approve and merge your code into the main project.
Click to reveal answer
What does a fork create in GitHub?
AA new branch in the original repository
BA backup of your local files
CA personal copy of a repository
DA pull request
What is the main purpose of a pull request?
ATo clone a repository
BTo request merging your changes into the original repository
CTo delete a branch
DTo create a new repository
Which step comes first in the fork and pull request workflow?
ACreate a pull request
BReview code
CMerge changes
DFork the repository
Why is it important to work on a fork instead of the original repository?
ATo avoid affecting the original project directly
BTo delete the original project
CTo speed up cloning
DTo create a backup
What do maintainers usually do after receiving a pull request?
AReview and decide to merge or request changes
BDelete the fork
CClone the fork
DCreate a new branch
Explain the fork and pull request workflow from start to finish.
Think about the steps you take to contribute to a project you don't own.
You got /6 concepts.
    Why is the fork and pull request workflow important for collaboration?
    Consider how teams avoid mistakes and keep projects organized.
    You got /5 concepts.

      Practice

      (1/5)
      1. What is the main purpose of forking a repository in the fork and pull request workflow?
      easy
      A. To clone the repository locally without any changes
      B. To delete the original project
      C. To create a personal copy of the project to work on independently
      D. To merge changes directly into the original repository

      Solution

      1. Step 1: Understand the concept of forking

        Forking creates a personal copy of the original project on your GitHub account, allowing you to work independently without affecting the original.
      2. Step 2: Identify the purpose in the workflow

        This personal copy lets you safely make changes and experiment before proposing them back to the original project.
      3. Final Answer:

        To create a personal copy of the project to work on independently -> Option C
      4. Quick Check:

        Fork = personal copy for safe work [OK]
      Hint: Fork means copy project to your account for safe changes [OK]
      Common Mistakes:
      • Confusing fork with clone
      • Thinking fork deletes original
      • Assuming fork merges changes automatically
      2. Which command correctly pushes a new branch named feature1 to your forked repository?
      easy
      A. git push origin main
      B. git push upstream feature1
      C. git push fork feature1
      D. git push origin feature1

      Solution

      1. Step 1: Identify the remote name for your fork

        By default, your fork is set as the remote named origin. The original repository is usually upstream.
      2. Step 2: Use the correct push syntax

        To push a branch named feature1 to your fork, use git push origin feature1.
      3. Final Answer:

        git push origin feature1 -> Option D
      4. Quick Check:

        Push branch to origin (your fork) = git push origin branch [OK]
      Hint: Push new branch to origin, not upstream [OK]
      Common Mistakes:
      • Using upstream instead of origin for push
      • Pushing main branch instead of feature branch
      • Using incorrect remote name like fork
      3. After forking a repo and pushing a branch fix-bug to your fork, what is the next step to propose your changes to the original project?
      medium
      A. Directly push fix-bug branch to the original repository
      B. Create a pull request from your fork's fix-bug branch to the original repo
      C. Merge fix-bug branch locally without pushing
      D. Delete your fork and clone the original repo again

      Solution

      1. Step 1: Understand the pull request purpose

        A pull request asks the original project to review and merge your changes from your fork's branch.
      2. Step 2: Identify the correct action after pushing

        After pushing your branch to your fork, you create a pull request targeting the original repository's branch.
      3. Final Answer:

        Create a pull request from your fork's fix-bug branch to the original repo -> Option B
      4. Quick Check:

        Push branch then create pull request [OK]
      Hint: Push branch, then open pull request to original repo [OK]
      Common Mistakes:
      • Trying to push directly to original repo without permission
      • Merging locally without sharing changes
      • Deleting fork before proposing changes
      4. You forked a repo and created a branch update-docs. You pushed it but forgot to sync your fork with the original repo first. What problem might occur when creating a pull request?
      medium
      A. Merge conflicts due to outdated fork base
      B. Your pull request will be automatically merged
      C. Your branch will be deleted automatically
      D. No changes will be visible in the pull request

      Solution

      1. Step 1: Understand syncing forks

        If your fork is behind the original repo, your branch may not include recent changes from the original.
      2. Step 2: Identify the pull request impact

        This can cause merge conflicts when the original repo tries to merge your changes because the base is outdated.
      3. Final Answer:

        Merge conflicts due to outdated fork base -> Option A
      4. Quick Check:

        Outdated fork causes merge conflicts [OK]
      Hint: Always sync fork before starting new branch [OK]
      Common Mistakes:
      • Assuming pull request merges automatically
      • Thinking branch deletes itself
      • Believing changes won't show without sync
      5. You forked a project and created two branches: featureA and featureB. You pushed both branches to your fork. How do you create pull requests so the original repo can review and merge these features independently?
      hard
      A. Create separate pull requests for each branch targeting the original repo's main branch
      B. Create one pull request combining both branches
      C. Push both branches to upstream and wait for automatic merge
      D. Merge featureB into featureA locally, then create a single pull request

      Solution

      1. Step 1: Understand pull request scope

        Each pull request represents changes from one branch to the original repo, allowing independent review.
      2. Step 2: Apply to multiple branches

        To keep features separate, create one pull request per branch targeting the original repo's main branch.
      3. Final Answer:

        Create separate pull requests for each branch targeting the original repo's main branch -> Option A
      4. Quick Check:

        One pull request per branch for independent review [OK]
      Hint: Make one pull request per branch for clear reviews [OK]
      Common Mistakes:
      • Combining branches in one pull request
      • Pushing branches directly to upstream without PR
      • Merging branches locally before PR