DEV Community

Cover image for Git Essentials: Commands You'll Actually Use Every Day
Ifedayo Agboola
Ifedayo Agboola

Posted on • Originally published at blackscripts.hashnode.dev

Git Essentials: Commands You'll Actually Use Every Day

Ever find yourself lost in Git documentation? This straightforward guide explains the essential Git commands you'll actually use daily... Instead of scrolling through man‑pages, bookmark this post: a no‑fluff cheat‑sheet of the handful of Git commands you’ll hit dozens of times a week.

In the next five minutes, you’ll get:

  • Plain‑English explanations for each command

  • Copy‑paste snippets you can drop straight into your terminal

  • A quick note on when—and why—it matters

Whether you’re committing on the train or rebasing before a pull request, these commands will keep your workflow fast and your history clean.

Ready to turn Git from “ugh, let me check the docs” into second nature? Let’s dive in!

Setting Up Git

Before we get to the commands, make sure Git is on your machine and stamped with your name.

Git vs GitHub (and friends)

Git is the tool that lives on your computer; GitHub, GitLab, and Bitbucket are just places to store and collaborate on your Git repositories online.

1. Install Git https://git-scm.com/downloads

2. Tell Git who you are (once)

git config --global user.name "Your Name"
git config --global user.email "you@example.com"
Enter fullscreen mode Exit fullscreen mode

Use --global once; omit it inside a repo if you need a different identity just for that project.

3. Start a new repo

mkdir my-project
cd my-project
git init
Enter fullscreen mode Exit fullscreen mode

That’s it—Git is ready. Next up: the everyday commands that keep your commits flowing.

Everyday Git Commands Cheat‑Sheet

(Think of Git like a notebook that keeps versions of your project. Commands below are plain‑English—with sample lines you can copy into your terminal.)

git status — “What did I change?”

  • Shows files you touched (red) and files you’ve marked for the next save point (green).
git status
Enter fullscreen mode Exit fullscreen mode

git log — History of save points

  • Lists past versions with date and author. Add --oneline for a skim‑friendly list.
git log --oneline
Enter fullscreen mode Exit fullscreen mode

Paths (branches)

  • Start a new path to try an idea, jump between paths, list them.
# start a new path
git branch feature-idea

# jump to it
git switch feature-idea   # (or git checkout feature-idea)

# see all paths
git branch
Enter fullscreen mode Exit fullscreen mode

git merge — Blend paths together

  • Combine another path into the one you’re on.
git switch main
git merge feature-idea
Enter fullscreen mode Exit fullscreen mode

git diff — Spot the difference

  • Shows exactly what changed line‑by‑line.
git diff            # working folder vs. staged area
git diff --staged   # staged area vs. last save
Enter fullscreen mode Exit fullscreen mode

git add → create the “next save” list

  • Tell Git which changed files should be in the next version.
git add index.html style.css
Enter fullscreen mode Exit fullscreen mode

(Everything you add turns green in git status.)


git commit — Save your files

  • Records the files you just add‑ed as a new save point.
git commit -m "Explain feature X"
Enter fullscreen mode Exit fullscreen mode

git stash — Stuff work into a drawer

  • Save messy changes so you can switch tasks, then pull them back.
git stash      # put away
# ...work on something else...
git stash pop  # take it out
Enter fullscreen mode Exit fullscreen mode

git rebase — Re‑play your changes on top of the latest copy

  • Makes history look cleaner by pretending you wrote your changes last.
git switch feature-idea
git rebase main
Enter fullscreen mode Exit fullscreen mode

SSH keys — Skip typing your password

Generate once, paste the public key on GitHub/GitLab, and you’re set.

ssh-keygen -t ed25519 -C "you@example.com"
Enter fullscreen mode Exit fullscreen mode

git push — Upload your save points

git push origin main
Enter fullscreen mode Exit fullscreen mode

git pull — Download & blend new saves

git pull       # same as: git fetch + git merge
Enter fullscreen mode Exit fullscreen mode

git fetch — Download only (peek, don’t blend)

git fetch
Enter fullscreen mode Exit fullscreen mode

Clone vs. Fork

Clone → just download the code

  • Use when you already have permission to push to the original repo (or you only need to read it).

  • Makes a local folder and a remote called origin that points to the real repo.

git clone git@github.com:org/project.git  # local copy
Enter fullscreen mode Exit fullscreen mode

Fork → make your own copy, then download

  • Use when you don’t have push rights but still want to contribute.
  1. Click Fork on GitHub/GitLab → a new repo under your account.

  2. Clone that copy:

    git clone git@github.com:you/project.git
    
  3. Keep in sync with the original (upstream) repo:

    git remote add upstream git@github.com:org/project.git
    git fetch upstream
    git rebase upstream/main   # or merge if you prefer
    
  4. Push to your copy and open a Pull Request so maintainers can review your changes.

    You just covered the essentials of Git by exploring commands you’ll genuinely use every day. Keep practicing these basics, and you'll quickly find yourself managing your code like a pro.

    I'll be writing more about general coding concepts and diving into Golang next. Follow along to level up your coding skills if you enjoyed this!

    Got stuck or have a question? Drop a comment, and let's troubleshoot together. Happy coding!


Top comments (0)