Skip to content

Instantly share code, notes, and snippets.

@sebnyberg
Last active December 25, 2023 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebnyberg/e7c52a608a280fd4cbcc18352e5b2192 to your computer and use it in GitHub Desktop.
Save sebnyberg/e7c52a608a280fd4cbcc18352e5b2192 to your computer and use it in GitHub Desktop.
Just some git notes

Git notes

Just a collection of git + magit things that I need to start remembering.

Usual working procedure

git switch -c my-branch

# ... do work
git fetch origin main
git rebase -i origin main

git push origin my-branch

gh pr create --fill
gh pr view --web

Searching

Git log
  • -Spattern - Look for differences that change the number of occurrences of the specified string (i.e. addition/deletion) in a file. Intended for the scripter’s use.
  • -G - Look for differences whose patch text contains added/removed lines that match
  • --pickaxe-all - When -S or -G finds a change, show all changes in the changeset, not just for matches.
  • -p - include diff
  • --grep - search log messages for pattern, many greps = any-match, unless --all-match is specified
  • -E - extended regexp
  • --invert-grep
  • --after
  • --before
  • --branches
  • --tags
  • --remotes
  • --glob
  • --oneline - commits on one line
git log -Spattern
git log -Gpattern
git log -Spattern -p # with diff
Git
Magit
  • Open the Magit log buffer with ll (lowercase L twice).
  • Customize the log with L and search for commit messages with -F or for changes with -G.
  • Once you entered your search value, press RET and refresh the buffer with g. You will see only commits that match your search.

https://stackoverflow.com/a/2928721/3745474

git log -Spattern
git log -Spattern -p # with git diffs

Searching

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment