Welcome to my repository! This is a collection of the most important and frequently used Git commands that I've compiled for myself and others.
Everything here is based on the excellent Learn Git course from boot.dev.
- Installing Git on Mac/Windows/Linux;
- Configuring user name and email;
- Initializing a repo with
git init; - The 3-stage workflow (Working, Staging, Repo);
- Checking status with
git status; - Staging files with
git add; - Committing changes with
git commit; - Viewing history with
git log;
- How Git stores data: blobs (content) & trees (filenames);
- What a commit object is (a snapshot + parent link);
- Peeking inside the
.gitdirectory; - Using
git cat-fileto inspect raw objects; - How Git's snapshot model saves space (deduplication);
- Config scopes:
--globalvs--local; - Viewing settings with
git config --list; - Adding, getting, and deleting configuration keys;
- The Hierarchy: How local settings override global ones;
- What is a branch? (A lightweight movable pointer);
- Creating and switching branches with
git switch; - Renaming
mastertomain; - Understanding
HEADand detached states; - Viewing decorations in
git log;
- Combining diverged history with
git merge; - Understanding Merge Commits (two parents);
- Fast-Forward merges (linear history);
- Handling the default editor (Vim) during merges;
- Rewriting history to move a branch base;
- How
git rebaseworks internally (replay commits); - The philosophy: Merge ("The Documentary") vs. Rebase ("The Storybook");
- The Golden Rule: Never rebase public branches;
- Undoing changes with
git reset; --soft: Undo the commit, keep the work staged;--hard: Delete the commit and the work (destructive);- Recovering "lost" commits using
git reflog;
- Understanding remotes (just another folder);
originvsupstream;- Adding a remote with
git remote add; - The difference between
git fetch(download) andgit merge(update);
- Git vs. GitHub (Tool vs. Service);
- HTTPS vs. SSH keys;
- Pushing code with
git pushand setting upstream (-u); - Pulling strategies (
pull.rebase false); - The Professional Workflow: Branch -> Push -> Pull Request -> Merge;