'git diff' doesn't give any output

前端 未结 9 2165
迷失自我
迷失自我 2020-12-08 09:11

If I run git diff I would expect to see a list of changes of my working directory relative to whatever had been committed before (or a list of the working direc

9条回答
  •  余生分开走
    2020-12-08 09:49

    You don't need any additional flags for git diff to work. First you create a file, and add it to the git repo with git add to staging and or execute a git commit to get it into your repository. Now, go to the file and make a change to it and save it. Just put a sentence in there stating "I will run the "git diff " command right after I save it". Save it. It is at that point you will see the difference when you run the git diff command. It will show the recent changes prior to executing a "git commit" or if you had only put the file initially into staging.

    \TestGit>git diff File2.txt
    diff --git a/File2.txt b/File2.txt
    index e2ba019..eff7299 100644
    --- a/File2.txt
    +++ b/File2.txt
    @@ -6,4 +6,6 @@ File two. Which is the second file that I will NOT add with the first file File1
    
     The goal here is to add the File1 but not the File 2
    
    -using git add File1.txt
    \ No newline at end of file
    +using git add File1.txt.
    +
    +So far I have just done a git add on this file.
    \ No newline at end of file
    

    The lines with the + signs is the added content. If you use the --cached flag, and get result,s then your git status for the same file should report that the file has not been committed. Once you commit the file, you will not get any output for git diff. even with the --cached flag.

提交回复
热议问题