Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git diff, shows the same line as both deleted and added

Tags:

git

git-diff

I accidently worked on the master where I had to open up a new branch.

I reverted it to its original form almost completely. At one class I get the following diff that I can not make sense out of.

index 4a9abb8..7c55879 100755
--- a/includes/site.inc.php
+++ b/includes/site.inc.php
@@ -142,11 +142,11 @@ class site{

        public $tplEngine = 'smarty';

-
+       
     private $_productsByType = array();
     private $logger;
-    protected $locale = 'tr_TR';
-
+    protected $locale = 'tr_TR';  
+    

It says that I have deleted and added the same thing, in principle there is no difference with the original index and I don't want this file to be seen as modified.

What should I do ? Thx.

like image 447
Pumpkin Avatar asked Jul 12 '12 13:07

Pumpkin


People also ask

Does git diff show deleted files?

You can use git diff --name-status, that will show you files that where added, modified and deleted.

What does ++ mean in git diff?

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.

What does git diff show you?

The git diff command helps you see, compare, and understand changes in your project. You can use it in many different situations, e.g. to look at current changes in your working copy, past changes in commits, or even to compare branches.

What is A and B in git diff?

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.


2 Answers

It's probably whitespace changes. You can run git diff -w, which will ignore any whitespace changes.

like image 109
mamapitufo Avatar answered Oct 07 '22 01:10

mamapitufo


Check spaces. The replaced "empty" looking lines have spaces in them. You may also have accidentally replaced tabs with spaces or vice versa.

like image 13
jpe Avatar answered Oct 06 '22 23:10

jpe