Is there any way to compare two files in Git without their formatting changes?

git diff --ignore whitespace
git diff ignore change
git diff two files
git diff specific file
git diff between commits
git diff best options
git diff default options
git diff whitespace only

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.

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

git-diff Documentation, Saving changes in a repo: git add adds a change in the working directory to the takes two input data sets and outputs the changes between them. git diff is a Raw output format The git diff command can be passed an explicit file path option. Invoking git diff without a file path will compare changes across the entire  In order to compare two files in the git bash you need to use the command: git diff <Branch name>..master -- Filename.extension This command will show the difference between the two files in the bash itself.

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

Git Diff, This behavior can be forced by --no-index. git diff [--options] --cached This is to view the changes between two arbitrary <commit>. git diff [--options] <commit>. For a more complete list of ways to spell <commit>, see "SPECIFYING The raw output format from "git-diff-index", "git-diff-tree", "git-diff-files" and "git diff --raw"  You can compare not just a single file, but all your changes at once. If you made changes in many files, just don’t mention any file name in the diff command which will diff all the changed files. // compares working directory with index, // i.e. shows the changes that are not staged yet. git diff // compares working directory with local repository. // shows the list of changes after your last commit.

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.

git-diff - Show changes between commits, commit , compares the trees named by the two arguments. git-diff-files [<pattern>. An output line is formatted this way: in-place edit :100644 100644 bcd1234 M file.c Without the -z option, pathnames with "unusual"  Comparing all changes. Invoking git diff without a file path will compare changes across the entire repository. The above, file specific examples, can be invoked without the ./path/to/file argument and have the same output results across all files in the local repo. Changes since last commit. By default git diff will show you any uncommitted changes since the last commit. git diff

git-diff(1) - Linux manual page, This is to view the changes between two arbitrary <commit>. git diff [<options>] For a more complete list of ways to spell <commit>, see "SPECIFYING This format shows an inline diff of the changes in the submodule contents Unless --​text is supplied patches of binary files without a textconv filter will be ignored. You can compare files of any types, including binaries and.jar files. To open the dialog, select two files to compare or a file to compare its versions and press Ctrl+D. The differences viewer provides a powerful editor that enables code completion, live templates, etc. Diff & Merge viewer

Differences viewer for files - Help, This dialog is displayed when you compare two files or two versions of a file (​local changes You can compare files of any types, including binaries and .jar files. Use this list to define how the differences viewer should treat whitespaces​. Ignore imports and formatting: changes within import statements and whitespaces  Specifying the files to compare. To compare two text files, you can type the paths of two files into the entry fields or use the buttons on the right-hand end of the entry fields to choose files to compare. The Browse button opens a file-browsing window and the Show history button displays a list of the files that you have recently compared. Double-click a row in the list to load and compare the relevant files.

Git Diff, The 'diff' command in Git will show you the same thing - the changes between two snapshots or files in unified diff format. This section will show you the different ways you can use diff to answer common quesions you might have about your repository. The answer is to just run 'git diff' with no arguments. $ git diff diff --git​  When you use history to compare versions, think in terms of file changes between two commits instead of file changes between two points in time. A recent change to a file in the master branch may have come from a commit created two weeks ago in a feature branch but was only merged yesterday.

Comments
  • Have you heard of git diff? If not you can read up on it here: git-scm.com/docs/git-diff
  • Save two files, old and new, and diff them with sublime text. If your formatting issue is tabs vs spaces (repo owner is kinda a jerk then), Sublime will also allow you to convert. Under View->Intention.
  • I am using git diff and its showing all line changes as formatting is different for both files. I am little novice in GIT and i want to use git UI insted of commands In SVN i used to copy my file and origin file in an diff tool and used to compare them. But now In GIT i cant copy both files sepratly from GITHUB.
  • Thanks alot i guess this will solve my 50% problem but still need to figure out formmating stuff.
  • I am using eclipse default formatter and reviewer is using intelij formatter so when he commits format changes and when i commit format changes ibasically i mean Placing of brackets ,breaking method Name etc So after removing white spaces also i can see some changes which i have not done