YouTip LogoYouTip

Git Diff

# git diff Command [![Image 3: Git Basic Operations](#)Git Basic Operations](#) * * * The git diff command compares file differences, i.e., the differences between files in the staging area and the working directory. The git diff command shows the differences between files that have been written to the staging area and those that have been modified but not yet written to the staging area. git diff has two main application scenarios. * Unstaged changes: **git diff** * View staged changes: **git diff --cached** * View all changes, both staged and unstaged: **git diff HEAD** * Show a summary instead of the full diff: **git diff --stat** Show the difference between the staging area and the working directory: $ git diff Show the difference between the staging area and the last commit: $ git diff --cached or $ git diff --staged Show the difference between two commits: $ git diff ... Enter the following content into the hello.php file: Use git status to check the status: $ git status-s A README AM hello.php $ git diff diff--git a/hello.php b/hello.php index e69de29..69b5711 100644 --- a/hello.php +++ b/hello.php @@ -0,0 +1,3@@ + git status shows the changes made since your last commit or the changes written to the cache, while git diff shows these changes line by line. Next, let's see the effect of running git diff --cached: $ git add hello.php $ git status-s A README A hello.php $ git diff--cached diff--git a/README b/README new file mode 100644 index 0000000..8f87495 ---/dev/null +++ b/README @@ -0,0 +1@@ +# Git Test diff--git a/hello.php b/hello.php new file mode 100644 index 0000000..69b5711 ---/dev/null +++ b/hello.php @@ -0,0 +1,3@@ + * * Git Basic Operations](#)
← Git ResetPython3 String Isupper β†’