How to Use GitHub: A Beginner's Guide to Git, Collaboration, and Portfolio
Key Takeaways
- GitHub is a web-based platform for Git repositories, used by over 100 million developers worldwide (as of 2025).
- Version control with Git lets you track changes, revert mistakes, and collaborate without overwriting each other's work.
- GitHub Actions automates workflows like testing and deployment, saving hours per week.
- Your GitHub profile acts as a living portfolio—recruiters often check it before interviews.
Introduction
If you're new to coding, you've probably heard about GitHub but felt overwhelmed by the jargon: branches, commits, pull requests, actions. I remember my first time—I accidentally deleted an entire project because I didn't understand what `git push --force` did. That mistake taught me the hard way why version control matters.
This guide walks you through the essentials: setting up Git, using GitHub for collaboration, automating tasks with Actions, and turning your profile into a portfolio that gets noticed. No fluff, just practical steps you can follow today.
What is Git and GitHub?
Git is a version control system that tracks changes in your code. It was created by Linus Torvalds in 2005 (yes, the same person who made Linux). GitHub is a cloud service that hosts Git repositories and adds collaboration features like issue tracking, code review, and Actions.
Think of Git as the engine in your car, and GitHub as the garage where you park, share, and repair it with friends.
Step 1: Install Git and Create a GitHub Account
1. Install Git: Go to [git-scm.com](https://git-scm.com) and download the version for your OS. On Windows, use Git Bash; on macOS/Linux, the terminal works fine.
2. Verify installation: Open your terminal and type `git --version`. You should see something like `git version 2.43.0`.
3. Create a GitHub account: Visit [github.com](https://github.com) and sign up. Use a professional username (e.g., `yourname-dev`) if you plan to use it for job applications.
4. Set up SSH key (optional but recommended): Run `ssh-keygen -t ed25519 -C "your_email@example.com"` and add the public key to GitHub under Settings > SSH and GPG keys.
Step 2: Your First Repository and Commit
Let's create a simple project to practice.
1. On GitHub, click the green "New" button.
2. Name your repo `my-first-repo`, add a description, and check "Add a README file".
3. Clone it to your computer:
```bash
git clone https://github.com/your-username/my-first-repo.git
cd my-first-repo
```
4. Create a file called `hello.py` with this content:
```python
print("Hello, GitHub!")
```
5. Stage and commit:
```bash
git add hello.py
git commit -m "Add hello.py with welcome message"
```
6. Push to GitHub:
```bash
git push origin main
```
Now refresh your repository page—you'll see your file. Each commit creates a snapshot you can revert to later.
Step 3: Collaboration with Branches and Pull Requests
Branches let you work on features or fixes without messing up the main code. Pull requests (PRs) are how you merge changes after review.
Scenario: You're working with a teammate on a website. You want to add a login feature.
1. Create a branch:
```bash
git checkout -b feature-login
```
2. Make changes (e.g., add `login.html`). Commit them:
```bash
git add login.html
git commit -m "Add login page"
```
3. Push the branch:
```bash
git push origin feature-login
```
4. On GitHub, click "Compare & pull request". Write a description: "Adds a login page with email validation."
5. Your teammate reviews the code, leaves comments, and approves. Then you merge the PR.
6. Back on your local machine, switch to `main` and pull the changes:
```bash
git checkout main
git pull origin main
```
Tip: Always pull before starting new work to avoid merge conflicts. If you get one, use `git mergetool` or manually edit the conflicting files.
Step 4: Automate with GitHub Actions
GitHub Actions runs tasks automatically when you push code. For example, you can run tests, deploy to a server, or format code.
Example: Run Python tests on every push
1. In your repo, create `.github/workflows/test.yml`:
```yaml
name: Python Tests
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: |
pip install pytest
- name: Run tests
run: pytest
```
2. Create a test file `test_hello.py`:
```python
def test_hello():
assert 1 + 1 == 2
```
3. Commit and push. Go to the Actions tab—you'll see the workflow run. If it fails, GitHub sends you an email.
Actions can also deploy to services like Netlify or AWS. I use one to auto-deploy my blog every time I push to `main`.
Step 5: Build a Portfolio with GitHub
Your profile README is often the first thing recruiters see. Here's how to make it stand out:
1. Create a repository with the same name as your username (e.g., `yourname/yourname`).
2. Add a `README.md` with:
- A brief intro (e.g., "I build web apps with Python and React")
- Links to your best projects (with descriptions)
- A fun fact (e.g., "I've contributed to 5 open-source projects")
3. Pin your top 6 repositories on your profile (Settings > Pinned items).
4. Use GitHub Pages to host a personal website from a repo. Just enable it under Settings > Pages.
Real example: My pinned repos include a weather app (300 stars), a CLI tool (used by 200 developers), and a blog template. Each has a clear README, screenshots, and a live demo link.
Comparison: GitHub vs. Alternatives
| Feature | GitHub | GitLab | Bitbucket |
| --------- | -------- | -------- | ----------- |
| Free private repos | Yes (unlimited) | Yes (unlimited) | Yes (up to 5 users) |
| CI/CD minutes/month | 2,000 | 400 | 50 |
| Community size | 100M+ users | 30M+ users | 10M+ users |
| Pages hosting | Yes (static sites) | Yes | No |
I prefer GitHub for its large community and Actions. GitLab is better for self-hosted setups.
Common Pitfalls and How to Avoid Them
- Forgetting to pull before pushing: Always run `git pull origin main` first. I once lost a day's work because I pushed without pulling.
- Committing secrets: Never commit API keys or passwords. Use a `.gitignore` file and tools like `git-secrets`.
- Messy commit messages: Write descriptive messages like "Fix login bug caused by missing CSRF token" instead of "fix stuff".
FAQ
Q: What's the difference between Git and GitHub?A: Git is a command-line tool for version control (runs locally). GitHub is a web platform that hosts Git repositories and adds collaboration features like pull requests, issues, and Actions. You can use Git without GitHub, but GitHub makes team work easier.
Q: How do I undo a commit?
A: Use `git revert HEAD` to create a new commit that undoes the last one. This is safe for shared branches. If you haven't pushed, use `git reset --soft HEAD~1` to uncommit but keep changes staged.
Q: Can I use GitHub for non-code projects?
A: Absolutely. People use it for writing books, managing legal documents, tracking research data, and even planning events. Markdown files and version control work well for any text-based project.
Conclusion
GitHub is more than a code hosting site—it's a tool for collaboration, automation, and showcasing your work. Start with a simple repo, practice branching with a friend, and add Actions to save time. Your future self (and potential employers) will thank you.
Remember: everyone makes mistakes with Git at first. That's why we have branches, commits, and backups. Just keep pushing (but pull first).