Linux, terminal and Git

Stage 5 of 8 · 8 lessons · ~3 weeks

Git fundamentals

Learn how Git actually stores your work, then use it daily: small commits, clear messages, branches, merging and rebasing, resolving conflicts and undoing mistakes without losing anything.

Start: How Git thinks: snapshots and history

Lessons· one lesson for each topic, in this order

  1. 1How Git thinks: snapshots and history
  2. 2Working tree, staging area and commits
  3. 3Small commits with clear messages
  4. 4.gitignore and what never goes in Git
  5. 5Branches for every change
  6. 6Merge and rebase
  7. 7Resolving conflicts calmly
  8. 8Undoing things safely

Do this

  • Create a repository with a .gitignore before the first commit.
  • Make 10 small commits using `git add -p` for at least two of them.
  • Rewrite three of your old commit messages into clear summaries (on a practice repo).
  • Create a branch, make changes on both it and main, and merge them.
  • Create a conflict on purpose and resolve it, then run your tests.
  • Rebase a feature branch onto main and compare the log with a merge.
  • Undo a commit with `git revert`, and recover a "lost" commit with `git reflog`.
  • Finish the main levels of Learn Git Branching.

Start with· follow one of these

  • BookFree
    Pro Git

    Scott Chacon and Ben Straub

    The free official Git book; chapters 2 and 3 cover everything in this stage properly

  • CourseFree
    The Missing Semester of Your CS Education

    MIT · Beginner

    The version control lecture teaches Git from its data model upwards, which makes commands make sense

Practise

Keep handy

Also worth your time

Before moving on: A personal repository with at least 20 meaningful commits across several branches, one merge, one rebase, one resolved conflict and one reverted commit, plus a short note describing each situation and the commands you used.

Tauseef's advice
Commit small and often, and read `git status` and `git diff` before every commit. Nearly everything in Git can be undone if it was committed, and almost nothing can be if it was not. When you are scared, stop, run `git status`, and remember that reflog exists.

Mark this stage as not done?