11 Forking a Repository and Making Changes with VSCode
Learning Objectives
Understand what it means to fork a repository on GitHub
Successfully fork a repository on GitHub and make changes locally using VSCode
Identify common errors and learn how to fix them
Step-by-Step Instructions
Part 1: Fork the Repository on GitHub
Navigate to the public repository you want to contribute to. (e.g., https://github.com/vmahan1998/GitHub_Basic_Skills.git)
Click the “Fork button in the top-right corner of the page.
Choose your GitHub account as the destination for the fork.
GitHub will create a copy of the repository under your account.
Part 2: Clone the Forked Repository Locally
Open Visual Studio Code (VSCode).
On the Welcome page, click Clone Git Repository.
- If you don’t see this option, install the GitHub Extension from the VSCode marketplace.
Paste the repository URL.
Choose a local folder where the repository should be saved.
Name the directory (typically the same as the repo name “GitHub_Basic_Skills”).
When prompted, click “Open” to begin working inside the cloned repository.
Part 3: Create New Branch
In VSCode, open the Source Control sidebar (click the branch icon or press
Ctrl+Shift+G).Click the branch name (e.g.,
main) in the lower-left corner or at the top of the Source Control pane.Select “Create new branch” from the dropdown.
Enter a name for your branch (e.g.,
new-message) and press “Enter”.VSCode will automatically switch you to the new branch.
Part 4: Make and Commit Changes Locally
- Edit the files in VSCode as needed (e.g., modify
EDIT_ME.mdor source code).
- Save your changes (
Ctrl+Sor File > Save).
- Open the Source Control pane.
- You should see your changed files listed.
- Hover over the file and click the + icon to stage it, or click the + icon next to Changes to stage all files.
- In the message box at the top, write a clear and descriptive commit message.
- Click the “✓” Commit button (or use the check mark icon).
- Click the “↥” Push icon in the bottom bar or from the Source Control menu to push your branch to GitHub.
Part 6: Create a Pull Request
Go to your forked repository on GitHub in a web browser.
GitHub will prompt you to compare & open a pull request.
Click “Compare & pull request”.
Add a descriptive title and explanation of your changes.
Click “Create pull request” to propose your contribution to the original repository.
Part 7: Merge Pull Request (for repository maintainers)
If you have permission, go to the pull request on the original repository.
Review the changes and click “Merge pull request”.
Confirm the merge and delete the feature branch if no longer needed.
Video Tutorial
Fork the Repository
Create a Pull Request
Merge a Pull Request
Troubleshooting
Remote repository not found
Make sure you created the repository on GitHub and copied the correct HTTPS or SSH URL. VSCode does not create remote repositories — it only connects to them.VSCode can:
Clone a remote repository from GitHub
Connect your local changes to a remote repo via Git
Push changes to an existing remote repository
Authentication failed
GitHub no longer supports passwords for HTTPS. If prompted, use a personal access token (PAT) instead. You can generate one at https://github.com/settings/tokens.Push fails due to README or file conflicts
If the GitHub repo was initialized with a README, license, or.gitignore, and your local repo wasn’t, this can cause merge conflicts. Create your GitHub repo without those options when pushing an existing local project.Git not detected
If Git features don’t appear in VSCode, install Git from https://git-scm.com and restart VSCode. Go to View > Command Palette > Git: Show Git Output to check if it’s recognized.Pushed changes not showing on GitHub
Make sure you pushed to the correct remote (usuallyorigin) and correct branch (mainormaster). You can check the branch in the bottom-left corner of VSCode.