why `git diff` reports no file change after `git add`

前端 未结 4 1956
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-01 16:16

 Why is that git diff thinks there are no changes

..even if git status reports them as modified?

$ git status
On bra         


        
4条回答
  •  终归单人心
    2021-02-01 17:05

    Please try git diff --staged command.

    Alternative options available are listed below.

    git diff

    shows changes between index/staging and working files. Since, in your case, git add moved your files-with-changes to staging area, there were no modifications shown/seen.

    git diff --staged

    shows changes between HEAD and index/staging. git diff --cached also does the same thing. staged and cached can be used interchangeably.

    git diff HEAD

    shows changes between HEAD and working files

    git diff $commit $commit

    shows changes between 2 commits

    git diff origin

    shows diff between HEAD & remote/origin

提交回复
热议问题