What is the git diff command for?

Asked

Viewed 11,475 times

10

  • 1

    http://rogerdudler.github.io/git-guide/index.pt_BR.html

2 answers

11


0

Basically, the command is git diff serves to show differences between files.

As an example, see an output of this command, showing the changes in the arquivo:

diff --git a/arquivo b/arquivo
index 10ff2df..84d4fa2 100644
--- a/arquivo
+++ b/arquivo
@@ -1,5 +1,5 @@
 linha1
 linha2
-esta linha foi removida
 linha4
 linha5
+esta linha foi adicionada

It can be used both to show differences between files not staged (files that have had some change):

git diff

Or files staged and not staged (in addition to the files cited above, it also shows changes to files added with git add):

git diff HEAD

Or even between commits:

git diff b4cb8d9..9c5733f

I believe the above commands are the most common ways to use the diff. As the command is very flexible and has several options of use, I suggest taking a look at official documentation.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.