Hacker News new | ask | show | jobs
Staging patches with Git add -p (simonholywell.com)
7 points by ankitg12 3 days ago
1 comments

I find grepdiff and this function are pretty useful if you want to pull certain hunks out of a large change set:

    #!/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
    }
https://gist.github.com/smuuf/76bde33d65b3dbbc2411e8519f3e6c...