Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git diff command showing entire file is modified instead of showing modified small part of code

Tags:

I am using git repository. Everything is working properly except git diff command. Whenever I modify any file then git diff command showing entire file is modified even though I modified small portion of the code.

What could be the reason git diff showing entire file modified instead of small portion of the code? Also let me know setting of git diff configuration.

diff --git a/application/routes.php b/application/routes.php
index 2842f8d..6629d16 100755
--- a/application/routes.php
+++ b/application/routes.php @@ -1,671 +1,676 @@ -<?php -/** - * Set the routes. Each route must have a minimum of a name, a URI and a set of - * defaults for the URI. - / -?> +<?php +/* + * Set the routes. Each route must have a minimum of a name, a URI and a set of + * defaults for the URI. + */ +?>
like image 571
Rahul Avatar asked May 26 '11 05:05

Rahul


People also ask

Why is git diff not showing anything?

In answer to the original question, git diff isn't showing anything because you have a brand new directory, with a newly added file, but there are zero changes in the file for git diff to show. git status is showing that you added a new file, but git diff is for showing changes within files.

How do I see changes in git diff?

You can run the git diff HEAD command to compare the both staged and unstaged changes with your last commit. You can also run the git diff <branch_name1> <branch_name2> command to compare the changes from the first branch with changes from the second branch. Order does matter when you're comparing branches.

What does git diff command do?

Comparing changes with git diff Diffing is a function that takes two input data sets and outputs the changes between them. git 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.

Which command will show the differences between the staged and committed versions of the file?

The git diff command shows the differences between the files in two commits or between your current repository and a previous commit.


2 Answers

Compare the output of git diff and git diff -b. Whitespace may be to blame. Reflowing text might be another (you didn't mention what you were storing).

like image 53
Seth Robertson Avatar answered Oct 31 '22 01:10

Seth Robertson


The file is either stored in unix mode or windows mode (with different line endings) and when you save the file you save it in the opposite format.

like image 43
ralphtheninja Avatar answered Oct 31 '22 02:10

ralphtheninja