Git
Version control day to day: commands, recovery and working with other people.
2026
- Add trailers during a rebaseAdd a co-author trailer to each replayed commit with git rebase, and skip duplicate lines with addIfDifferent.
- Pick a diff algorithm for git blameCompare Myers and Histogram on a reordered file, then inspect the commit before attributing a line to the author of the move.
- Find the last commit for each fileUse git last-modified to find the latest commit for each file in a directory, at HEAD or in an older committed tree.
- Clone one commit with git clone --revisionCheck out a pinned Git commit with clone --revision, and add --depth=1 when your build needs the tree without its ancestors.
- Silence hints with git --no-adviceUse Git’s global --no-advice flag to remove remediation hints from script logs while preserving command output and failure status.
- Recover a deleted branch from the reflogUse git reflog list to find a surviving log, inspect the deleted branch’s old tip, and restore a branch name at that commit.
- Skip redundant commits when cherry-pickingUse git cherry-pick --empty=drop to backport a range whose changes partly exist on the release branch, and check what Git added.
2025
- Make fixup commits squash automaticallySet rebase.autoSquash so interactive rebase moves fixup commits beside their targets, then inspect the order before saving.
- Fetch every remote with fetch.allMake plain git fetch update your fork and upstream, then check the remote tracking branches before you integrate changes.
- Show the base in conflicts with zdiff3Use zdiff3 conflict markers to see the merge base and trim matching lines from the edges of a conflict.
- Schedule repo upkeep with git maintenanceRegister a clone with git maintenance, run a named task such as prefetch by hand, and see what git maintenance start needs from the system.
- Inspect merge conflict fixes with --remerge-diffgit show --remerge-diff redoes a merge and diffs it against the commit, so conflict fixes and extra edits made while resolving become readable.
- Reuse conflict resolutions with git rerereEnable git rerere to reuse a conflict resolution the next time Git recognizes the same conflict.
- Find a bad commit with git bisect runUse a test script with git bisect run to find the first bad commit and skip revisions the script cannot test.
- Use git switch and restore instead of checkoutUse git switch to change branches and git restore to recover or unstage files, even when a branch and file share a name.
- Fix origin/HEAD after a default branch renameAfter a default branch rename, repair a stale origin/HEAD with git remote set-head or configure fetch to follow the remote.
2023
- Review a PR without stashing your workUse git worktree add to check out a second branch in its own folder, review it, and remove it, while your edits stay put.
- Rebase stacked branches with --update-refsRebase the top of a branch stack with --update-refs to move branch tips that point into the rewritten commits.