This exercise walks you through the basic Git workflow using VS Code’s Source Control tab and GitHub’s web interface. By the end, you will have cloned a repository, created a branch, made changes, and merged them back.
Content developed by Ben Rambo-Martin
Prerequisites
1. Clone the Repository
- Open VS Code.
- Click the Source Control tab in the left sidebar (the icon that looks like a branching graph).
- If no folder is open, you will see a Clone Repository button. Click it.
- Paste your institute’s repository URL (e.g.,
https://github.com/your-org/your-repo.git) into the input box that appears at the top of the window. - Choose a local folder to clone into and click Select as Repository Destination.
- When prompted, click Open to open the cloned repository in VS Code.
2. Create a Branch
- In the Source Control tab, click the … (more actions) menu at the top of the panel.
- Navigate to Branch > Create Branch….
- Name your branch something descriptive, e.g.,
update-readme-yourname. - Press Enter — VS Code will create the branch and switch to it automatically.
- You can confirm the active branch by looking at the bottom-left corner of the VS Code status bar.
3. Edit the README
- Click the Explorer tab in the left sidebar to view your files.
- Open the
README.mdfile. -
Add a line with your name and today’s date, for example:
## Contributors - Your Name (2026-04-16) - Save the file (
Ctrl+S/Cmd+S).
4. Stage and Commit
- Click the Source Control tab in the left sidebar.
- You should see
README.mdlisted under the Changes section. - Hover over
README.mdand click the + (Stage Changes) icon to move it to the Staged Changes section. - Type a commit message in the Message text box at the top of the Source Control panel, e.g.,
Add contributor name to README. - Click the Commit button (checkmark icon) to commit your staged changes.
5. Push to GitHub
- After committing, the Commit button in the Source Control tab will change to Publish Branch (since this is a new branch).
- Click Publish Branch to push your branch to GitHub.
- If prompted, authenticate with GitHub and select the remote to publish to.
6. Create a Pull Request and Merge (GitHub Website)
- Open your repository on github.com.
- You should see a banner saying your branch was recently pushed. Click Compare & pull request.
- Review the changes, add a title and description if needed, then click Create pull request.
- Once the pull request is created and any reviewers have approved, click Merge pull request.
- Click Confirm merge.
- Optionally, delete the branch on GitHub by clicking Delete branch.
7. Pull the Merged Changes Locally
- In VS Code, click the Source Control tab.
- Click the … menu and navigate to Branch > Checkout to…, then select
main. - Click the … menu again and select Pull to pull the latest changes from GitHub.
- Your local
mainbranch now includes the merged changes.
You have now completed a full Git workflow — clone, branch, edit, commit, push, and merge. This is the foundation for collaborating on code with your team.