Git Essentials Every Developer Should Know

A
Author
30 Sep, 2026 1 min read 132 views

Git records snapshots of your project over time. Once you understand three places (working directory, staging area, repository), the everyday commands make sense.

The three areas

  • Working directory - your files as you edit them.
  • Staging area - changes you've selected for the next commit (git add).
  • Repository - the history of commits (git commit).

Daily workflow

git status                         # what changed?
git diff                           # unstaged changes
git add src/cart.js                # stage a file
git add -p                         # stage hunk by hunk (review as you go)
git diff --staged                  # what will be committed
git commit -m "Fix rounding in cart total"
git log --oneline --graph -15

Branches

git switch -c feature/coupon-codes   # create and switch
git switch main                      # go back
git branch -d feature/coupon-codes   # delete a merged branch

A branch is just a movable pointer to a commit, which is why creating one is instant.

Working with a remote

git clone git@github.com:acme/shop.git
git fetch                             # download new commits, change nothing locally
git pull --rebase                     # fetch + replay your local commits on top
git push -u origin feature/coupon-codes

Settings worth adding

git config --global user.name "Asha Kumar"
git config --global user.email "asha@example.com"
git config --global init.defaultBranch main
git config --global pull.rebase true
git config --global push.autoSetupRemote true

Good habits

  • Commit small, focused changes with clear messages.
  • Pull often to avoid big conflicts.
  • Never commit secrets; add .env to .gitignore before your first commit.
  • Read git status output; it usually tells you the next command to run.
Was this article helpful?

Comments

No comments yet. Have a question or a tip? Be the first to share it.

Leave a comment

Comments are reviewed before they appear.