Tech & AI

Git and GitHub for Beginners: The Only Commands You Need

Git and GitHub for Beginners: The Only Commands You Need

Version control without the fear: the core Git workflow, the commands you will actually type, and how to fix common mistakes.

Git records the history of a project so you can change things without losing the ability to go back. GitHub is a website that hosts Git repositories and adds collaboration on top. Almost everything else is detail.

The mental model

Three places hold your work:

  • Working directory โ€” the files as they are on your computer right now.
  • Staging area โ€” the changes you have chosen to include in the next save.
  • Repository โ€” the recorded history of saved commits.

A commit is a snapshot with a message. That is the whole idea: take snapshots often, and describe them well.

One-time setup

git config --global user.name "Your Name"
git config --global user.email "you@example.com"

The daily workflow

This is the loop you will repeat forever:

git status                  # what has changed?
git add .                   # stage everything you want to save
git commit -m "Add SQL article"   # save a snapshot
git push                    # send it to GitHub

With GitHub, start by getting the project:

git clone https://github.com/user/repo.git

Branches

A branch is a parallel line of work, so you can try something without disturbing the main version:

git switch -c feature/new-page   # create and switch
git switch main                  # go back

When the work is ready, merge it:

git switch main
git merge feature/new-page
Rule of thumb: keep main working at all times, and do experiments on branches.

Seeing what happened

git log --oneline     # compact history
git diff              # unstaged changes
git show <commit>     # details of one commit

Good commit messages make this history useful. Write the why, briefly, in the imperative: "Fix date sorting on the blog index".

Fixing common mistakes

SituationFix
Staged a file you did not wantgit restore --staged file
Want to discard local editsgit restore file
Bad commit message, not pushedgit commit --amend -m "New message"
Need to undo a pushed commitgit revert <commit> (creates a safe inverse commit)
Work in progress, need to switchgit stash then later git stash pop

git revert is the safe undo for shared history. Avoid rewriting commits that others may already have.

A note on merge conflicts

A conflict happens when two changes touch the same lines. Git marks the file like this:

<<<<<<< HEAD
your version
=======
their version
>>>>>>> other-branch

Edit the file to the version you actually want, delete the marker lines, then git add and commit. Conflicts are normal, not a sign you broke something.

Habits that keep you out of trouble

  • Commit small and often. Large commits are hard to understand and hard to undo.
  • Commit only working states on your main branch.
  • Pull before you push. It prevents most avoidable conflicts.
  • Never commit secrets. Passwords and API keys belong in environment variables.
  • Write messages for your future self, who will have forgotten everything.

The bottom line

You need surprisingly little Git: status, add, commit, push, pull, branch, switch, merge. Learn those, and version control becomes a safety net instead of a source of anxiety.

Related articles

Practical Prompt Engineering for AI Tools

Practical Prompt Engineering for AI Tools

Better prompts are less about magic words and more about clear thinking. Here are the habits that reliably get more useful answers from AI tools.

๐Ÿ“ Tech & AI ๐Ÿ—“ September 30, 2026 โฑ 8 min read
Using AI in Your Daily Work Without Losing Your Edge

Using AI in Your Daily Work Without Losing Your Edge

AI assistants can save real hours each week โ€” if you use them for the right tasks. A practical guide to weaving them into everyday work.

๐Ÿ“ Tech & AI ๐Ÿ—“ October 1, 2026 โฑ 8 min read
Cybersecurity Basics: Protecting Your Accounts and Devices

Cybersecurity Basics: Protecting Your Accounts and Devices

Most breaches do not start with brilliant hackers. They start with a reused password, an ignored update, or a link that should not have been clicked. Here is how to close those gaps.

๐Ÿ“ Tech & AI ๐Ÿ—“ October 2, 2026 โฑ 8 min read

Suggested summaries

Tech & AI Homo Deus book cover

Homo Deus

Yuval Noah Harari ยท 2016
โ˜…โ˜…โ˜…โ˜…โฏจ 4.5

Harari looks past famine, plague and war to ask what humanity will chase next: immortality, engineered happiness and god-like power over life itself.

Tech & AI
Tech & AI Life 3.0 book cover

Life 3.0

Max Tegmark ยท 2017
โ˜…โ˜…โ˜…โ˜…โฏจ 4.5

Max Tegmark maps the choices ahead for artificial intelligence โ€” utopia, catastrophe or something in between โ€” and why values matter as much as code.

Tech & AI
Tech & AI The Pragmatic Programmer book cover

The Pragmatic Programmer

Andrew Hunt ยท 1999
โ˜…โ˜…โ˜…โ˜…โ˜… 5

Hunt and Thomas distil decades of hard-won craft into practical habits: stay curious, keep code honest, automate the boring parts, and own your work.

Tech & AI