Skip to content

Instantly share code, notes, and snippets.

@oscarteg
Created February 12, 2024 14:22
Show Gist options
  • Save oscarteg/97cbe246f0ba4f01aa08729631fd7ed5 to your computer and use it in GitHub Desktop.
Save oscarteg/97cbe246f0ba4f01aa08729631fd7ed5 to your computer and use it in GitHub Desktop.
Git
Command Description
git blame -L 28,43 path/to/file Shows who modified each line in a specific range of a file.
git blame -L :'class LocalFile' filepath Blames a block of code in a file matching a specific pattern.
git log -L28,43:filepath Lists commits that last touched a specified region of a file.
git blame -w Ignores whitespace changes in git blame.
git blame -C Follows code movement across files in git blame. Can be used up to three times.
git diff --word-diff Shows word-level differences in git diff output.
git config --global rerere.enabled true Enables reuse of recorded resolution of conflicts.
git config --global rerere.autoUpdate true Automatically updates the index with the result of rerere resolution.
git config --global branch.sort -committerdate Sorts branches by last commit date in descending order.
git push --force-with-lease Safely force-pushes, ensuring no updates were pushed to the branch since your last fetch.
git maintenance start Starts Git maintenance tasks to optimize repository performance.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment