#Version Control
18 posts
Overwrote Commits with git push --force — Recovery and Prevention
A recovery guide for when a force push wipes a teammate's commits from the remote branch. It covers the three recovery paths — a teammate's local clone, your remote-tracking reflog, and the hosting service's records — plus the settings that prevent a repeat.
Committed a Large File to Git? History Cleanup and Migrating to LFS
What to do when a push is rejected by the 100 MB limit or the repository has swollen to several GB. From the diagnosis that finds the largest blobs, through filter-repo history cleanup, to migrating still-needed files to Git LFS.
Committed a Secret to Git? Rotate the Key First, Then Clean History with filter-repo
A response procedure for the incident where an AWS key, an API token, or a .env file was committed and pushed. Priority one is not cleaning history but invalidating the key. We also cover rewriting history with filter-repo and the prevention tooling.
Getting Out of Git Detached HEAD — Causes and Recovering Commits
What the "You are in detached HEAD state" warning actually means, explained through its structure, with an escape route for each situation. Includes how to keep commits made in this state by putting a branch on them.
Recovering Deleted Git Commits and Branches with reflog
How to recover commits wiped by git reset --hard and branches deleted with -D, using the reflog. Covers what the reflog records, what it does not, and the cases where recovery is impossible.
Practical Git Workflows #7: Monorepos and Git — sparse-checkout, Submodules, and LFS
Why Git slows down as a repository grows, and when to reach for partial clone, sparse-checkout, submodules, and Git LFS. The final part of the Practical Git Workflows series.
Practical Git Workflows #6: stash, cherry-pick, bisect — Everyday Tools
stash to absorb urgent context switches, cherry-pick to move a single commit to another branch, and bisect to find the commit that introduced a bug by binary search. Three tools that are hard to do without at the moment you need them.
Practical Git Workflows #5: Running Pull Requests — Review Size, Commit Messages, and Draft PRs
Criteria for splitting PRs into reviewable sizes, the Conventional Commits convention, draft PRs and self-review, PR templates and branch protection. Running Pull Requests from the operations point of view.
Practical Git Workflows #4: Resolving Conflicts — Structure, mergetool, and rerere
Understand conflicts through the base, ours, and theirs structure and handle them with tools. Why ours and theirs look flipped during a rebase, zdiff3 markers, the VS Code merge editor, and rerere so you never solve the same conflict twice.
Practical Git Workflows #3: Interactive Rebase — Cleaning Up Commits with squash and fixup
Interactive rebase reshapes commits into readable units before you open a PR. We cover the six todo-list commands, the fixup and autosquash workflow, and pushing a rewritten branch safely with force-with-lease.
Practical Git Workflows #2: rebase vs merge — Decision Criteria and the Golden Rule
See through diagrams how rebase re-applies commits as brand-new ones, and build criteria for choosing between rebase and merge. Includes the structural reason you must never rebase a shared branch.
Git Basics #6: GitHub and Your First Pull Request
Create a repository on GitHub, connect your local repository, and follow a first Pull Request end to end — from branching through review feedback to merging and cleanup. The final part of the Git Basics series.