0
0
Gitdevops~30 mins

Fork and pull request workflow in Git - Mini Project: Build & Apply

Choose your learning style9 modes available
Fork and Pull Request Workflow
📖 Scenario: You want to contribute a small fix to an open-source project on GitHub. You will use the fork and pull request workflow to safely make your changes and propose them to the original project.
🎯 Goal: Learn how to fork a repository, clone your fork locally, create a new branch, make a change, push it to your fork, and open a pull request to the original repository.
📋 What You'll Learn
Use the exact repository URL https://github.com/example/project.git
Create a fork on GitHub (simulated by a command)
Clone your fork using the URL https://github.com/yourusername/project.git
Create a branch called fix-typo
Make a change by creating a file fix.txt with content Fixed typo
Commit the change with message Fix typo in documentation
Push the branch fix-typo to your fork
Open a pull request from fix-typo branch of your fork to the main branch of the original repository
💡 Why This Matters
🌍 Real World
Open-source contributors use fork and pull request workflows to safely propose changes without affecting the original project directly.
💼 Career
Understanding this workflow is essential for collaborating on shared codebases in software development jobs and open-source projects.
Progress0 / 4 steps
1
Fork and clone the repository
Simulate forking the repository by creating a new remote called origin with URL https://github.com/yourusername/project.git. Then clone your fork locally using git clone https://github.com/yourusername/project.git.
Git
Need a hint?

Use git remote add origin <url> to add your fork as a remote. Then use git clone <url> to copy it locally.

2
Create a new branch for your fix
Create a new branch called fix-typo using git checkout -b fix-typo.
Git
Need a hint?

Use git checkout -b fix-typo to create and switch to the new branch.

3
Make a change and commit it
Create a file named fix.txt with the content Fixed typo. Then stage the file using git add fix.txt and commit with the message Fix typo in documentation using git commit -m "Fix typo in documentation".
Git
Need a hint?

Use echo "Fixed typo" > fix.txt to create the file. Then add and commit it with the exact message.

4
Push your branch and open a pull request
Push the branch fix-typo to your fork using git push origin fix-typo. Then simulate opening a pull request from your fix-typo branch to the main branch of the original repository by printing Pull request opened from fix-typo to main.
Git
Need a hint?

Use git push origin fix-typo to upload your branch. Then print the message exactly as shown.