Skip to content

Commit History

You'll learn the six git commands that cover most real use, so you can save your work in a way you can undo, branch and explain before a bad edit costs you a weekend.

About

Git is the one tool every coder uses whether they like it or not, and you don't need the whole thing. Six commands cover about ninety percent of real use. Learn them on a project you don't care about, so your first mistake is a cheap one. Your first merge conflict will look like git has destroyed your file, and it hasn't, so take a breath and read the markers. Pull requests and working with strangers are a different badge over in Open Source.

At a glance

Per requirement
15 XP
Completion bonus
75 XP
Requirements
6
Takes
An evening or two
Skill level
Novice (never tried it)
Cost
Free
Supplies
Nothing special
Where
At home
Other people
On your own

Requirements

  1. 1
    Install git, set your name and email, and turn a folder into a repository. Run git config --global for user.name and user.email, then git init inside a folder that has a couple of files in it. The hidden .git folder it creates is the whole history, so never delete it by accident. Take a screenshot of git status showing your untracked files. Photo
  2. 2
    Make five commits, each with a message that says why, not what. Use git add and then git commit -m. The diff already shows what changed, so the message is for the reason behind it. A bad message is 'fixed stuff', and a good one is 'stop crash when input is empty'. Take a screenshot of git log --oneline with your five lines. Photo
  3. 3
    Break a file badly on purpose, then throw the change away. Edit a file into nonsense, look at the damage with git diff, then run git restore on the file to bring it back. That one command is the reason you're learning this. Film a short clip of the break and the restore. Video
  4. 4
    Make a branch, change something on it, and merge it back. Use git switch -c with a name, commit a change, switch back, and run git merge. Then delete the branch. You've just done the thing teams do a hundred times a day. Take a screenshot of git log --oneline --graph showing the merge. Photo
  5. 5
    Cause a merge conflict on purpose and resolve it. Change the same line on two branches, merge them, and open the file with the <<<<<<< markers in it. Pick a side, delete the markers and commit. Everyone fears this until they've done it once on purpose. Take a screenshot of the markers, then of the clean merge commit. Photo
  6. 6
    Push the repo to a remote and clone it back into a different folder. GitHub, GitLab or Codeberg all have free accounts. Before you push, read every file once for passwords and API keys, because public is forever and deleting the commit later doesn't unpublish it. Then git remote add, git push, git clone into a new folder, and check that the log matches. Now your laptop can die and the work survives. Take a screenshot of the fresh clone with its git log. Photo