Git guides
Every published Git guide, newest first, with practical examples you can copy into your own project.
3,815 guides across 14 topics
Topics
Popular Git guides
Most readLatest Git guides
Page 2 of 2Git reflog: Recovering Lost Commits and Deleted Branches
Every ref movement is logged locally for ninety days. How to undo a reset, restore an amended commit, and what fsck can still find when the log is gone.
Git log, diff, show, and blame: Searching History by Content
Two dots are asymmetric, three dots compare against the merge base, -S counts occurrences while -G matches diffs. The filters that turn a slow search into a fast one.
Git Cherry-Pick: Commits, Ranges, and Conflict Handling
A..B excludes A, -x records where the change came from, and one change with two hashes breaks later reverts. Backports need a policy, not a habit.
Git Stash: push, pop, apply, and Partial Stashing
A stash is a commit with two or three parents, and it leaves untracked files behind by default. When a temporary branch or a worktree is the better tool.
Git reset vs revert vs restore: Soft, Mixed, Hard, and Undoing Safely
Three commands with three depths: reset rewrites the branch, revert adds a commit, restore touches files. Which one is still safe after a push.
Git Interactive Rebase: Squash, Fixup, and --onto Workflows
Rebase replays commits onto a new base; --onto moves only a subset. Autosquash folds fixups without editing the todo list, and force-with-lease makes the result shareable.
Git Merge: Fast-Forward, Three-Way, and Conflict Resolution
Fast-forward moves a pointer; a three-way merge compares both tips to a merge base. Where ours and theirs invert, and why a squashed merge blocks re-merging.
Git switch, checkout, and Detached HEAD Recovery
switch moves HEAD, restore touches files, checkout does both badly. How to leave a detached HEAD with your commits intact, and how to get back.
Git Staging Area: status, add -p, commit --amend, and Partial Commits
The index is what a commit actually contains, which makes partial commits possible and commit -a dangerous. What amend rewrites, and when that is safe.
Git Remote and Upstream Tracking: init, clone, and Branch Relationships
An upstream is a config line, not a copy of a branch. Why pull refuses to run, what a shallow clone breaks, and how origin and upstream differ in a fork.