I know that by using the commands
git show / git diff
I can get the line changes, nevertheless they print line modifications as a + line preceded by a - line. I recall finding somewhere an option to only show the modification in one line, with the changes printed in red (old) and green (new).
Note:
To clarify it a little, for example, by using the command git show <commitId>
I will be getting:
- <property>horses</property>
+ <property>humans</property>
The minus line appears in red and the plus line in green. What I want to accomplish is to have the change in only one line, still I do not remember how the prefix appeared, but I believe it was something like:
+ <property>[horses]humans<property>
Where the whole line appears green and the word horses appears red. I know this can be done because I did it in the past with some random command I got from a page that sadly cannot remember.
If
$ git diff --word-diff=color
, as Peter mentioned, is not the output you want, you could try:
$ git diff --word-diff=plain
This will print some additional brackets {}
and signs + -
, around the differences. But it also will show the same colorful output as word-diff=color
will do.
To show differences per word in the 7th last commit, use:
$ git diff HEAD~7 --word-diff=plain
$ git diff
»
- // check for twice same password
+ // check is password twice
$ git diff --word-diff=color
»
// check for twice sameis password twice
$ git diff --word-diff=plain
»
// check [-for twice same-]{+is+} password {+twice+}
git diff --word-diff=color
将逐字逐句显示差异。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.