Some people are really a big fan of ‘vim’ and so they also use ‘vimdiff’ over the default ‘diff’ utility. ‘vimdiff’ shows you a side by side diff which is very easy to read (shown in the image below).

Now if you are using ‘git’ and you run ‘git diff’ you will get a diff which is not very human readable. Thats where ‘vimdiff’ comes.
> git diff
diff --git a/todo-java-app/pom.xml b/todo-java-app/pom.xml
index 96aebba..6b9af3f 100644
--- a/todo-java-app/pom.xml
+++ b/todo-java-app/pom.xml
@@ -1,5 +1,6 @@
+testing
4.0.0
com.rokoder
todo-java-app
@@ -48,4 +49,4 @@
5.1.18
-
\ No newline at end of file
+
>
>
‘git’ supports ‘vimdiff’ as a diff tool. Run the below command to change the diff tool to ‘vimdiff’.
>git config --global diff.tool vimdiff >
Now to access this diff tool.
> git difftool Viewing: 'todo-java-app/pom.xml' Hit return to launch 'vimdiff': >
It will show open the vimdiff window. If you are OK/happy with ‘git difftool’ command you are done:

But if you run `git diff` well you wont see ‘vimdiff’ but the same results as shown above. So to fix this run.
>git config --global diff.external git_vimdiff_wrapper >
Now we have to create ‘git_vimdiff_wrapper’ script with
#!/usr/bin/env sh vimdiff "$2" "$5" > /dev/tty
Then
chmod +x git_vimdiff_wrapper
Make sure it is in the path. And now when you run ‘git diff’ it will show ‘vimdiff’ as it was showing for ‘git difftool’.
> git diff 2 files to edit

If you want the default diff behavior then just use the below command:
>git diff --no-ext-diff
diff --git a/todo-java-app/pom.xml b/todo-java-app/pom.xml
index 96aebba..6b9af3f 100644
--- a/todo-java-app/pom.xml
+++ b/todo-java-app/pom.xml
@@ -1,5 +1,6 @@
+testing
4.0.0
com.rokoder
todo-java-app
@@ -48,4 +49,4 @@
5.1.18
-
\ No newline at end of file
+
>
>
Leave a Reply