1

Sometimes I may look through the git log for some lost code only in commits.

eg: search some code like XXX using git log -p -S XXX, but the output may have leading +/-, I want to hide them to copy the code directly to my project, since the + code is green, - code is red, I can easily distinguish them.

Thanks for any other way to copy code from git log easily.

feistiny
  • 95
  • 6

1 Answers1

0

You could try:

git log -p -S XXX --color-words

As mentioned in "Git: remove leading plus/minus from lines in diff" that would remove the +/-.

As seen in git log:

The command takes options applicable to the git rev-list command to control what is shown and how, and options applicable to the git diff-* commands to control how the changes each commit introduces are shown.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250