git diff --Display difference

The git diff command is a command to display the difference.

#Display difference
git diff

Here is an example of the output of the git diff command.

$git diff
diff --git a /README.md b / README.md
deleted file mode 100644
index 372dc9d3..00000000
--- a / README.md
+++ / dev / null
@@-1,5 +0,0 @@
diff --git a /README.md b / README.md
deleted file mode 100644
index 372dc9d3..00000000
--- a / README.md
+++ / dev / null
@@-1,5 +0,0 @@
-<H1>
--Introduction to Perl Seminar
-</h1>
――――
――――
diff --git a / templates / index.html b / templates / index.html
index 66c755ea..f0b95399 100644
--- a / templates / index.html
+++ b / templates / index.html
@@-2,7 +2,7 @@

 An introductory course on <b> Perl text processing </b> and <b> regular expressions </b>. Perl is a programming language that excels at <b> text processing </b> and <b> regular expressions </b> in the fields of <b> Linux server management </b> and <b> Web system development </b>. Active in. Perl as the basis for text processing and regular expressions
Explains the logging language from the basics. You can also learn Linux and web development. Hello World!

-Perl is installed on most Linux / Unix and is backwards compatible and stable
It has a good reputation for being operational.
+ Perl is installed on most Linux / Unix and is backwards compatible and stable
It has a good reputation for being operational. How nice.

 <h4> Introduction to Perl Programming </h4>

The git diff command, with no arguments, displays the difference between the working directory and commit ready state. The commit-ready state is the most recent commit if you have not prepared for commit.

In other words, note that the "git diff" command doesn't show any diffs after you've prepared for a commit.

Show the difference between the most recent commit and the commit ready state

To see the difference between the most recent commit and the commit ready state, use the "--cached" option and type "git diff --cached".

# Show the difference between the most recent commit and the commit ready state
git diff --cached

Note that you need to use the "--cached" option to see what diffs are actually added to the new commit after you prepare it for commit with "git add.".

Show diffs between specific commits

To see the difference between a particular commit, specify two commit IDs as arguments.

git diff commit ID1 commit ID2

Use the git log command to find out the commit ID.

This is a sample that specifies the commit ID.

git diff 30ce650c40cd05632fc8a992a7bff9d79dbaaa08 016d2063f2ed90d14ba9cea1a7ef1c2f962a003b

Show the difference between the current commit and the previous commit

Let's display the difference between the current commit and the previous commit. The branch called HEAD indicates the beginning of the current branch, and the symbol "^" can be written as follows by using the display of the previous branch.

git diff HEAD ^ HEAD

Furthermore, you can omit it and write as follows.

git diff HEAD ^

Show the difference between a specific commit and the previous commit

To see the difference between a particular commit and the previous commit:

git diff 30ce650c40cd05632fc8a992a7bff9d79dbaaa08 ^ 30ce650c40cd05632fc8a992a7bff9d79dbaaa08

Show branch diffs

To see the branch diffs, do the following: If you know that a branch is an alias for commit, you know.

git diff main some_branch

Associated Information