Bird
Raised Fist0
Gitdevops~20 mins

Pull request process in Git - Practice Problems & Coding Challenges

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
Challenge - 5 Problems
🎖️
Pull Request Pro
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of this git command after pushing a branch?
You run the following commands:
git checkout -b feature-xyz
git push origin feature-xyz

What is the typical output message you will see after the push completes successfully?
Git
git checkout -b feature-xyz
git push origin feature-xyz
ASwitched to a new branch 'feature-xyz'\nEverything up-to-date
Bfatal: remote origin already exists.
CEnumerating objects: 5, done.\nCounting objects: 100% (5/5), done.\nDelta compression using up to 8 threads\nCompressing objects: 100% (3/3), done.\nWriting objects: 100% (3/3), 300 bytes | 300.00 KiB/s, done.\nTotal 3 (delta 0), reused 0 (delta 0)\nremote: Resolving deltas: 100% (0/0), done.\nTo github.com:user/repo.git\n * [new branch] feature-xyz -> feature-xyz
Derror: failed to push some refs to 'origin'
Attempts:
2 left
💡 Hint
Think about what git shows when a new branch is pushed to the remote.
🧠 Conceptual
intermediate
1:30remaining
What is the main purpose of a pull request in Git workflows?
Choose the best description of why teams use pull requests.
ATo merge code changes directly to the main branch without review.
BTo request feedback and review before merging code changes into a shared branch.
CTo delete branches that are no longer needed.
DTo create a backup of the repository on a remote server.
Attempts:
2 left
💡 Hint
Think about collaboration and quality control in teams.
🔀 Workflow
advanced
2:30remaining
What is the correct sequence of commands to create a pull request branch, push it, and open a pull request on GitHub CLI?
Arrange the following commands in the correct order to create a feature branch, push it to origin, and open a pull request using GitHub CLI.
A1,4,2,3
B1,2,4,3
C4,1,2,3
D1,4,3,2
Attempts:
2 left
💡 Hint
Remember you must commit changes before pushing, and open the PR after pushing.
Troubleshoot
advanced
1:30remaining
What error will you see if you try to push a branch without permission to the remote repository?
You run:
git push origin feature-branch

but you do not have write access to the remote repo. What error message will git show?
Aerror: failed to push some refs to 'origin'\nfatal: unable to access 'https://github.com/user/repo.git/': The requested URL returned error: 403
Bfatal: remote origin already exists.
CEverything up-to-date
Dfatal: not a git repository (or any of the parent directories): .git
Attempts:
2 left
💡 Hint
403 error means forbidden access.
Best Practice
expert
2:00remaining
Which option best describes a recommended practice before merging a pull request?
Select the best practice to ensure code quality before merging a pull request into the main branch.
ADelete the feature branch before merging to keep the repo clean.
BMerge immediately after opening the pull request to save time.
CForce push to the main branch to overwrite history.
DRun automated tests and have at least one team member review the code changes.
Attempts:
2 left
💡 Hint
Think about quality control and collaboration.

Practice

(1/5)
1. What is the main purpose of a pull request in Git?
easy
A. To ask your team to review and merge your code changes
B. To delete a branch from the repository
C. To create a new branch locally
D. To clone a repository to your computer

Solution

  1. Step 1: Understand the role of a pull request

    A pull request is a request to merge code changes and get feedback from the team.
  2. Step 2: Identify the correct purpose

    Options B, C, and D describe other Git actions unrelated to pull requests.
  3. Final Answer:

    To ask your team to review and merge your code changes -> Option A
  4. Quick Check:

    Pull request = code review request [OK]
Hint: Pull request means asking for code review and merge [OK]
Common Mistakes:
  • Confusing pull request with branch creation
  • Thinking pull request deletes branches
  • Mixing pull request with cloning repositories
2. Which Git command is used to upload your local branch to the remote repository before creating a pull request?
easy
A. git clone origin branch-name
B. git pull origin branch-name
C. git push origin branch-name
D. git fetch origin branch-name

Solution

  1. Step 1: Identify the command to upload local changes

    The git push command sends local commits to the remote repository.
  2. Step 2: Match the correct syntax

    git push origin branch-name uploads the specified branch to the remote named origin.
  3. Final Answer:

    git push origin branch-name -> Option C
  4. Quick Check:

    Push = upload branch to remote [OK]
Hint: Push uploads your branch to remote before pull request [OK]
Common Mistakes:
  • Using git clone instead of git push
  • Confusing git pull with git push
  • Using git fetch which only downloads data
3. After pushing your branch and creating a pull request, what is the expected output when you run git status on your local branch?
medium
A. On branch feature-xyz nothing to commit, working tree clean
B. On branch feature-xyz your branch is ahead of 'origin/feature-xyz' by 1 commit
C. On branch main nothing to commit, working tree clean
D. On branch feature-xyz You have unmerged paths.

Solution

  1. Step 1: Understand the state after pushing and creating pull request

    After pushing, local and remote branches are synced, so no new commits locally.
  2. Step 2: Interpret git status output

    "nothing to commit, working tree clean" means no changes locally; branch is up to date.
  3. Final Answer:

    On branch feature-xyz nothing to commit, working tree clean -> Option A
  4. Quick Check:

    Clean status means local branch matches remote [OK]
Hint: Clean git status means branch is synced after push [OK]
Common Mistakes:
  • Thinking branch is ahead after push
  • Confusing branch names
  • Expecting unmerged paths without conflicts
4. You created a pull request but forgot to push your latest commit. What error will you most likely see when trying to create the pull request?
medium
A. Pull request created successfully with all commits
B. Error: No commits found on branch to compare
C. Merge conflict detected automatically
D. Remote branch does not exist

Solution

  1. Step 1: Understand the pull request creation process

    A pull request compares your remote branch with the base branch.
  2. Step 2: Identify the error when branch is not pushed

    If you forget to push, the remote branch does not exist, causing an error.
  3. Final Answer:

    Remote branch does not exist -> Option D
  4. Quick Check:

    Pull request needs remote branch [OK]
Hint: Push branch first or remote branch won't exist [OK]
Common Mistakes:
  • Assuming pull request works without pushing
  • Expecting merge conflict before push
  • Ignoring remote branch creation step
5. You want to ensure your pull request is merged only after at least two team members approve it. Which GitHub feature should you configure?
hard
A. Enable auto-merge without reviews
B. Branch protection rules with required reviews set to 2
C. Use git rebase to combine commits
D. Create a new branch for each reviewer

Solution

  1. Step 1: Identify how to enforce review requirements

    GitHub branch protection rules allow setting required number of reviewers before merge.
  2. Step 2: Match the feature to the requirement

    Setting required reviews to 2 ensures at least two approvals before merging.
  3. Final Answer:

    Branch protection rules with required reviews set to 2 -> Option B
  4. Quick Check:

    Branch protection = enforce review count [OK]
Hint: Use branch protection rules to require reviews [OK]
Common Mistakes:
  • Confusing auto-merge with review enforcement
  • Thinking git rebase controls reviews
  • Creating branches per reviewer is unnecessary