Skip to content

Git for Beginners: A Map of the Essential Commands

Git remembers the history of your code. Seven commands cover most everyday work — here is how they fit together.

By Virtuvia Editorial DeskPublished 1 min read
Git logo
Photo: Jason Long / Wikimedia Commons, CC BY 3.0

Key takeaways

  • A commit is a snapshot of the project with a message explaining the change.
  • Staging (git add) chooses what goes into the next commit.
  • Branches let you experiment safely without touching the main version.

The basic workflow#

terminal
git init
git status
git add index.html
git commit -m "Add home page"
git log --oneline

git init creates a new repository, git status shows what changed, git add stages changes, and git commit records them permanently. git log shows the history.

Branches for safe experiments#

terminal
git branch new-feature
git switch new-feature

On a branch you can change code freely. When you are happy with the result, you merge the branch back into the main version.

Source and further reading

  1. Pro Git— git-scm.com