Is there any way to compare two files in Git witho

2019-08-10 20:57发布

I have committed some code with some format but the origin has some other format. The reviewer is asking me to revert all my changes and I am searching for some UI tool or some way in Git to remove formatting and give the actual result.

3条回答
狗以群分
2楼-- · 2019-08-10 21:16

If you use intellij, consider using the version control tool provided by it.

The below link details on how to get a diff between two branches. https://stackoverflow.com/a/49642681/2960555

for a single file diff, You can right click on file -> git -> compare.

A new window will gets opened. select ignore options in that.

查看更多
Bombasti
3楼-- · 2019-08-10 21:24

I think you might have a look at git diff, in particular the two following options:

-b, --ignore-space-change
   Ignore changes in amount of whitespace. This ignores whitespace at line end, and considers all other sequences of one or more whitespace characters to be equivalent.

-w, --ignore-all-space
   Ignore whitespace when comparing lines. This ignores differences even if one line has whitespace where the other line has none.

So running git diff --ignore-all-space

However, if what you define by formatting is not just whitespace, I guess you have to do it by hand

查看更多
We Are One
4楼-- · 2019-08-10 21:27

Kdiff3 is the tool i needed to get my work done This is a GUI tool for UNIX systems which can compare two file remove conflicts check for changes

查看更多
登录 后发表回答