It's very often that I need to copy-and-paste part of a GitHub commit. Whenever I do this, however, I find myself manually going down each line and hitting Delete
to strip all of the +/- signs.
Is there a more convenient way to copy part of a GitHub commit to the clipboard?
Suggestions involving Chrome extensions/your personal projects are welcome.
Update July 2018:
Unselectable diff markers
The
+
and-
diff markers are no longer copied to your clipboard when you copy the contents of a diff.
Yay!
Original answer (August 2017)
You could:
curl the diff itself from GitHub (without cloning the all repo history):
https://github.com/foo/bar/commit/${SHA}.patch
pipe it to a sed to remove the +/-:
.... | sed -r "s/^([^-+ ]*)[-+ ]/\\1/" | less -r
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With