0
0
Gitdevops~20 mins

Fork and pull request workflow in Git - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Fork and Pull Request Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
What is the main purpose of a fork in GitHub workflow?

In the fork and pull request workflow, why do developers create a fork of a repository?

ATo create a personal copy of the repository where they can freely make changes without affecting the original project
BTo directly push changes to the original repository without review
CTo delete the original repository and replace it with their own version
DTo merge the original repository into their local machine automatically
Attempts:
2 left
💡 Hint

Think about why you might want your own space to work on a project without changing the original code immediately.

💻 Command Output
intermediate
2:00remaining
What is the output of this git command sequence?

Assume you have forked a repository and cloned your fork locally. You run these commands:

git remote -v
git fetch upstream
git merge upstream/main

What does the git remote -v command output show?

Git
git remote -v
ANo remotes configured
B
origin  https://github.com/originalowner/repo.git (fetch)
origin  https://github.com/originalowner/repo.git (push)
C
upstream  https://github.com/yourusername/repo.git (fetch)
upstream  https://github.com/yourusername/repo.git (push)
D
origin  https://github.com/yourusername/repo.git (fetch)
origin  https://github.com/yourusername/repo.git (push)
upstream  https://github.com/originalowner/repo.git (fetch)
upstream  https://github.com/originalowner/repo.git (push)
Attempts:
2 left
💡 Hint

Remember that origin points to your fork and upstream points to the original repository.

🔀 Workflow
advanced
2:30remaining
Correct order of steps to contribute using fork and pull request

Arrange these steps in the correct order to contribute a fix to a project using the fork and pull request workflow.

A3,2,4,1
B2,4,3,1
C2,3,4,1
D4,3,2,1
Attempts:
2 left
💡 Hint

Think about starting from GitHub, then working locally, then proposing changes.

Troubleshoot
advanced
2:00remaining
Why does this pull request show no changes?

You forked a repository, cloned it, made changes, committed, and pushed to your fork. But when you open a pull request, it shows no changes. What is the most likely cause?

AYou forgot to fork the repository before cloning
BYou pushed your changes to a different branch than the one used in the pull request
CYou merged the upstream branch into your fork before pushing
DYou deleted your fork after pushing changes
Attempts:
2 left
💡 Hint

Check if the branch you pushed matches the branch selected in the pull request.

Best Practice
expert
2:30remaining
What is the best practice to keep your fork updated with the original repository?

You have a fork of a repository and want to keep it updated with the latest changes from the original project. Which command sequence is best practice?

A
git fetch upstream
 git checkout main
 git merge upstream/main
 git push origin main
B
git checkout main
 git push origin main
 git fetch upstream
C
git clone upstream
 git push origin main
D
git pull origin main
 git push upstream main
Attempts:
2 left
💡 Hint

Think about fetching changes from the original repo, merging locally, then pushing to your fork.