Forking a Repository and Creating a Pull Request
Today, I want to share my experience of learning how to fork a repository, create a branch, and make a pull request. Initially, I tried doing this through the Coursera lab environment using Visual Studio Code, but I ran into some problems. So, I decided to switch to my personal setup on Git Bash. Here’s how it went down:
Starting with the Coursera Lab
I began with the Coursera lab, which provided a Visual Studio Code environment. The task was simple: fork a repository, make some changes, and then create a pull request. However, I quickly hit some roadblocks.
Issues Encountered
After several attempts and facing the same issues repeatedly, I decided to switch gears and use my personal laptop with Git Bash. This turned out to be a great move.
Switching to Git Bash on My Laptop
Here’s what I did using Git Bash:
Step 1: Forking the Repository
First, I forked the repository on GitHub. I chose the octocat/Spoon-Knife repository for practice.
Step 2: Cloning the Forked Repository Locally
Next, I cloned the forked repository to my local machine.
gh repo clone <my-username>/Spoon-Knife
3. Navigate to the Repository: After cloning, I navigated into the directory:
cd Spoon-Knife
Step 3: Creating and Checking Out a New Branch
To keep my changes organized, I created a new branch.
领英推荐
git checkout -b my-branch
Step 4: Making Changes
I then made some changes to the index.html file.
nano index.html
2. Add My Details: I added my name and the certification I am working on to the file.
Step 5: Adding and Committing Changes
With the changes made, I staged and committed them.
git add index.html
2. Commit the Changes: I committed the changes with a message:
git commit -m "Added my name and certification to index.html"
Step 6: Pushing Changes to GitHub
Next, I pushed my changes to the forked repository on GitHub.
git push origin my-branch
Step 7: Creating a Pull Request
Finally, I created a pull request to merge my changes into the original repository.
Conclusion
This experience taught me a lot about version control and using GitHub effectively. Despite the initial problems with the Coursera lab environment, switching to my personal setup allowed me to complete the task successfully. Now, I have a better understanding of forking a repository, creating a branch, making changes, and submitting a pull request. This hands-on practice was really helpful, and I’m excited to use these skills in future projects.