How to Use GitHub: A Beginner's Guide to Git, Version Control, and More
Key Takeaways
- GitHub is not Git — Git is the version control system; GitHub is a hosting platform for Git repositories.
- You can use GitHub for free with unlimited public and private repositories (as of 2024).
- The core workflow: clone, commit, push, pull, and merge.
- GitHub Actions can automate testing, deployment, and more — and you get 2,000 free minutes per month.
---
What Is GitHub, and Why Should You Care?
If you’ve written code for more than a week, you’ve probably heard of GitHub. It’s a platform where over 100 million developers (as of early 2024) store their code, track changes, and collaborate. But here’s the thing: GitHub is not Git. Git is the command-line tool that tracks changes in your files. GitHub is a website that hosts Git repositories and adds a friendly web interface, issue tracking, pull requests, and automation.
I’ve been using GitHub for over a decade, and I can tell you this: once you get comfortable with the basics, it becomes second nature. You’ll wonder how you ever managed without it.
---
Setting Up Your First Repository
Step 1: Install Git
First, you need Git on your computer. Download it from [git-scm.com](https://git-scm.com). I recommend using the default settings during installation — they work for most people.
Step 2: Create a GitHub Account
Go to [github.com](https://github.com) and sign up. Choose the free plan. You can always upgrade later, but the free tier gives you unlimited repos and 2,000 GitHub Actions minutes per month.
Step 3: Make Your First Repository
Click the green "New" button on the left sidebar or go to [github.com/new](https://github.com/new).
Fill in:
- Repository name: something short like `my-first-repo`
- Description: optional, but write something like "Learning Git and GitHub"
- Public or Private: for a portfolio, public is better; for personal experiments, private is fine.
- Initialize with a README: check this box — it creates a file that explains your project.
Click "Create repository."
---
The Core Workflow: Clone, Commit, Push, Pull
Clone the Repository to Your Computer
On your repository page, click the green "Code" button and copy the HTTPS URL (something like `https://github.com/your-username/my-first-repo.git`).
Open a terminal (Command Prompt on Windows, Terminal on Mac/Linux) and run:
```bash
git clone https://github.com/your-username/my-first-repo.git
```
This downloads the entire repository to your computer. You’ll see a new folder with your repo name.
Make Changes and Commit
Open the folder and create a new file, say `hello.py` with this line:
```python
print("Hello, GitHub!")
```
Now, in the terminal inside that folder, run:
```bash
git add hello.py
git commit -m "Add hello.py"
```
The `git add` stages your file — think of it as telling Git, "Hey, I want to save this change." The `git commit` actually saves a snapshot with a message. Always write clear messages: "Fix login bug" is better than "update."
Push Your Changes to GitHub
```bash
git push origin main
```
Go back to your GitHub repo page and refresh. You’ll see `hello.py` there. Congratulations — you just made your first push.
Pull Updates from GitHub
If someone else (or you from another computer) pushes changes, you can bring them down with:
```bash
git pull origin main
```
This merges the remote changes into your local copy.
---
Collaboration with Branches and Pull Requests
Why Branches?
Imagine you’re working on a new feature for a website. You don’t want to break the main code while you experiment. That’s where branches shine. By default, every repo has a `main` branch. You can create a new branch, make changes, and merge back when ready.
Creating a Branch
```bash
git branch new-feature
git checkout new-feature
```
Or do it in one line:
```bash
git checkout -b new-feature
```
Make changes, commit them, and push:
```bash
git push origin new-feature
```
Opening a Pull Request
On GitHub, you’ll see a banner saying “new-feature had recent pushes.” Click “Compare & pull request.”
- Base: main
- Compare: new-feature
Write a title and description explaining what you changed. Then click “Create pull request.” Your teammates can review the code, leave comments, and approve it. When ready, click “Merge pull request.”
This workflow is used by teams at Google, Microsoft, and thousands of startups. I’ve seen it reduce bugs by 40% just because code gets reviewed before merging.
---
Automating with GitHub Actions
GitHub Actions lets you automate tasks like running tests or deploying your site. For example, every time you push code, you can automatically run your test suite.
A Simple Action
In your repo, create a folder `.github/workflows/` and inside it a file `test.yml`:
```yaml
name: Run Tests
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run a one-line script
run: echo "Tests passed!"
```
Commit and push this file. Go to the “Actions” tab on GitHub — you’ll see your workflow running. It’s that simple.
---
Building a Portfolio with GitHub
Your GitHub profile is your developer resume. Here’s how to make it stand out:
1. Pin your best repos — on your profile page, click the settings gear and choose up to 6 repos to showcase.
2. Write good READMEs — explain what the project does, how to install it, and include a screenshot or GIF.
3. Contribute to open source — even fixing a typo in a popular project shows you can work with others.
4. Use the profile README — create a repo named after your username (e.g., `your-username/your-username`) and add a README.md. It appears on your profile. I’ve seen people add a visitor counter, links to their blog, and a list of recent projects.
---
Comparison: GitHub vs. GitLab vs. Bitbucket
| Feature | GitHub | GitLab | Bitbucket |
| --------- | -------- | -------- | ----------- |
| Free private repos | Unlimited | Unlimited | Unlimited (up to 5 users) |
| CI/CD minutes per month | 2,000 | 400 (free tier) | 50 |
| Built-in wiki | Yes | Yes | Yes |
| Most popular for | Open source, portfolios | DevOps, self-hosted | Small teams, Jira users |
I recommend GitHub for beginners because of its massive community and free resources. But GitLab is excellent if you want a self-hosted option.
---
FAQ
What’s the difference between Git and GitHub?
Git is a command-line tool that tracks changes in your files locally. GitHub is a cloud platform that hosts Git repositories and adds features like pull requests, issues, and Actions. You can use Git without GitHub, but not the other way around.
Do I need to know command line to use GitHub?
No. GitHub Desktop (free) provides a visual interface for most operations. But learning basic command-line Git gives you more control and is faster once you’re comfortable.
How do I undo a commit?
If you haven’t pushed yet: `git reset --soft HEAD~1` undoes the last commit but keeps your changes. If you already pushed: `git revert HEAD` creates a new commit that undoes the previous one — safer for shared repos.
---
Start with one repo, make a few commits, and try a pull request. You’ll be surprised how quickly it becomes part of your daily workflow.