Skip to content

Instantly share code, notes, and snippets.

@smuuf
Created May 26, 2022 22:53
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 smuuf/76bde33d65b3dbbc2411e8519f3e6c18 to your computer and use it in GitHub Desktop.
Save smuuf/76bde33d65b3dbbc2411e8519f3e6c18 to your computer and use it in GitHub Desktop.
Git add / stage lines matching regex
#!/bin/bash
# Put this into your .bashrc, or whatever.
function git-add-regex {
git diff -U0 | grepdiff -E "$1" --output-matching=hunk | git apply --cached --unidiff-zero
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment