My question is rather simple, though I have had no luck finding an answer.
I'd like to remove the leading plus/minus symbols from each line in git diff
. Before you ask why I wish to do this, allow me to outline my reasons:
git
)Is there some config option for doing this? If not, how can I do this in a way that still allows me to page through my diff less
-style?
Any insight would be greatly appreciated.
When viewing a combined diff, if the two files you're comparing have a line that's different from what they were merged into, you will see the ++ to represent: one line that was added does not appear in either file1 or file2.
In most cases, Git picks A and B in such a way that you can think of A/- as "old" content and B/+ as "new" content. Let's look at our example: Change #1 contains two lines prepended with a "+". Since no counterpart in A existed for these lines (no lines with "-"), this means that these lines were added.
Comparing changes with git diffgit diff is a multi-use Git command that when executed runs a diff function on Git data sources. These data sources can be commits, branches, files and more.
Computing diffsThe diff is dynamically generated from the snapshot data by comparing the root trees of the commit and its parent. Git can compare any two snapshots in time, not just adjacent commits. To compare two commits, start by looking at their root trees, which are almost always different.
The simple way I have seen is this.. Much easy to remember (The text format changes. So you need to know the code change)
git diff --color-words
Here is a way to make it default
If you are using linux add the following command to your ~/.bashrc file
Then you can use gitdiff without space as another command .
alias gitdiff='git diff --color-words'
Update:
To set alias directly through git config (Without the help of ~/.bashrc)
https://git-scm.com/book/en/v2/Git-Basics-Git-Aliases
Thank you @dylankb for this.
Example: If you enter the command git config --global alias.ci commit
;
then you can use git ci
for rest of your life for committing!!
Happy Gitting :)
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