Git & GitHub with VS Code: A Student’s Guide
Hope you enjoy!
~>Sir Roy C:
- Git & GitHub with VS Code: A Student’s Guide
Welcome to the world of version control! With Git and GitHub, you can save your code, track changes, and collaborate with friends—all inside Visual Studio Code (VS Code). This guide will help you get started, step by step.
1. What is Git? What is GitHub?
- Git: A tool that tracks changes in your code, like a “save game” for your projects.
- GitHub: A website where you can store your code online, share it, and collaborate with others.
2. Setting Up Git
Install Git
If you haven’t already, follow your installation guide to install Git on your computer.
Configure Your Identity
Open a terminal in VS Code (Ctrl + backtick or View > Terminal) and enter:
git config --global user.name "Your Name"
git config --global user.email "your@email.com"
This tells Git who you are, so your commits are labeled correctly.
3. Sign Up for GitHub
- Go to github.com and click Sign up.
- Choose a username, enter your email, and create a password.
- Follow the prompts to finish setting up your account.
- (Optional but recommended) Add a profile picture and bio!
4. Connect VS Code to GitHub
Sign In to GitHub
- Click the Accounts icon in the lower-left corner of VS Code.
- Click Sign in with GitHub.
- Follow the prompts in your browser to authorize VS Code.
Now, VS Code can talk to your GitHub account!
5. Using Git in VS Code: The Basics
VS Code has built-in Git tools—no need to memorize commands!
Useful Git Functions in VS Code
- Initialize a Repository: Click the Source Control icon (the branch) and click “Initialize Repository.”
- Commit: Type a message (e.g., “Add my first file”) and click the checkmark.
- Pull and Push to GitHub: Click the “Sync Changes” icon (⟳) to downloadn commits and upload your commits to GitHub.
- View History: Click the clock icon to see previous commits.
- Create/Checkout Branches: Click the branch name in the bottom-left and select or create a branch.
- Clone a Repository: Use
Ctrl+Shift+P> “Git: Clone” and paste the repo URL.
Bonus: Resolving Merge Conflicts
If you and a friend edit the same file, VS Code will highlight conflicts and let you choose which changes to keep.
6. Typical Workflow
- Make changes to your code.
- Stage the files you want to save.
- Commit with a message describing your changes.
- Push to GitHub to back up your work or share with others.
7. Tips for High School Students
- Commit often! It’s like saving your game.
- Use clear commit messages (e.g., “Fix bug in quiz scoring”).
- Don’t be too afraid to experiment—Git lets you undo most mistakes.
- Collaborate: Share your repo link with classmates for group projects.
8. More Resources
With these tools, you’re ready to code, collaborate, and conquer your projects! 🚀