On this page 9 sections
Short answer: Git is a tool that tracks changes to your code so you can save versions, undo mistakes and work in branches. GitHub is a website that stores Git projects online so you can back them up, share them and collaborate. You only need about ten commands to start.
Git vs GitHub
- Git runs on your computer and records the history of your project.
- GitHub hosts that history online, adds pull requests, issues and collaboration, and acts as your public portfolio.
Every developer job expects Git. It is also the easiest way to show employers and clients your work (developer portfolio guide).
Step 1: Install and configure
Install Git from the official site, then set your name and email:
git config --global user.name "Your Name"
git config --global user.email "you@example.com"Step 2: The commands you’ll use every day
git init # start tracking a folder
git status # see what changed
git add . # stage all changes
git commit -m "Message" # save a snapshot
git log --oneline # see history
git branch feature-x # create a branch
git switch feature-x # move to that branch
git merge feature-x # merge it into the current branch
git pull # get the latest changes from GitHub
git push # send your commits to GitHubStep 3: Put your project on GitHub
- Create a free GitHub account
- Click New repository, give it a name, don’t add files
- In your project folder run:
git init
git add .
git commit -m "First commit"
git branch -M main
git remote add origin https://github.com/yourname/your-repo.git
git push -u origin mainStep 4: Branches and pull requests
A branch is a safe copy where you build a feature without breaking the main code. When it is ready, open a pull request on GitHub to review and merge it. This is how teams work, and practising it alone builds good habits.
Writing good commit messages
- Short and specific: “Add contact form validation” not “update”
- One logical change per commit
- Present tense is the common convention
The .gitignore file
List files Git should never track, like node_modules/, .env and build folders. Never commit passwords or API keys. If you do, change them immediately, because deleting the commit doesn’t remove it from history everywhere.
Make your GitHub profile work for you
- Pin your best repositories
- Write a README for each project: what it does, screenshots, how to run it
- Add a profile README with a short bio and links
You can see how I document projects on my GitHub and tech projects page.
Frequently asked questions
Is GitHub free?
Yes, for public and private repositories for individuals, with paid plans for extra features.
What is the difference between git pull and git fetch?
fetch downloads changes without applying them. pull downloads and merges them into your current branch.
How do I undo my last commit?
git reset --soft HEAD~1 undoes the commit but keeps your changes. Be careful with --hard, which deletes changes.
Do I need Git if I work alone?
Yes. It gives you history, backups and the freedom to experiment safely.
