Back to Blog
GitTutorial
Getting Started with Git and GitHub
Computer ClubJan 15, 20265 min read
Why Version Control Matters
If you've ever worked on a project and ended up with files named final.docx, final_v2.docx, final_REAL_final.docx, you already understand the problem that version control solves.
Git is a version control system that tracks every change you make to your code. GitHub is a platform that hosts your Git repositories online, making it easy to collaborate with others.
Setting Up Git
First, install Git from git-scm.com. Then configure it with your name and email:
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"Your First Repository
Create a new folder for your project and initialize Git:
mkdir my-project
cd my-project
git initNow create a file, add it, and make your first commit:
echo "# My Project" > README.md
git add README.md
git commit -m "Initial commit"Connecting to GitHub
- Create a new repository on github.com
- Copy the repository URL
- Connect your local repo:
git remote add origin https://github.com/username/my-project.git
git push -u origin mainKey Commands to Remember
| Command | What It Does |
|---|---|
git status | See what's changed |
git add . | Stage all changes |
git commit -m "message" | Save a snapshot |
git push | Upload to GitHub |
git pull | Download latest changes |
git branch feature | Create a new branch |
git checkout feature | Switch to a branch |
Next Steps
Once you're comfortable with the basics, explore branching, pull requests, and collaborative workflows. Check out Learn Git Branching for an interactive tutorial.
Happy coding!