'git status' shows changed files, but 'git diff' doesn't

前端 未结 15 1900
轻奢々
轻奢々 2020-12-12 11:37

I\'ve had a look at all similar questions. However, I\'ve double checked and something strange is definitely happening.

On one server (Solaris with Git 1.8.1) I clon

15条回答
  •  死守一世寂寞
    2020-12-12 12:09

    Short Answer

    Running git add sometimes helps.

    Example

    Git status is showing changed files and git diff is showing nothing...

    > git status
    On branch master
    Changes not staged for commit:
      (use "git add ..." to update what will be committed)
      (use "git checkout -- ..." to discard changes in working directory)
    
            modified:   package.json
    
    no changes added to commit (use "git add" and/or "git commit -a")
    > git diff
    > 
    

    ...running git add resolves the inconsistency.

    > git add
    > git status
    On branch master
    nothing to commit, working directory clean
    > 
    

提交回复
热议问题