Git - some files are marked as changed but 'git diff' doesn't show anything

前端 未结 6 615
广开言路
广开言路 2021-02-02 07:11

I am quite new to Git, thus maybe I am missing something here.

dan@one:/var/www/$ git status -s
M  GoogleChromeExtension.js
M  ApiClient.js

So

相关标签:
6条回答
  • 2021-02-02 07:26

    I just recently had this problem, and found it happened because I changed my .gitattributes file for the repository. Have you changed any of your .gitattributes files recently? Are all the files that are changed of the same type? My recent issues affected *.sql files, for example. When I undid the change to .gitattributes, the source files became unchanged again.

    0 讨论(0)
  • 2021-02-02 07:37

    git diff doesn't show the difference between last two commits. git diff shows difference between last commit and the changes you have done to your code.

    0 讨论(0)
  • 2021-02-02 07:43

    Do a git diff --cached - it compares the HEAD and index, ie stuff added for commit.

    Just a git diff is between index and working directory, so if all the changes have been staged for commit, you won' see anything in git diff

    The third form is git diff <commit> which compares working directory and commit. So doing git diff HEAD will also give you the diff that you want as well.

    0 讨论(0)
  • 2021-02-02 07:43

    Depending on exactly what is going on, there may be two solutions to this. It would be best if you didn't use short mode since it hides information important for debugging this.

    If you expect changes, try running git diff HEAD to compare the working directory to the last commit. If you have already git added the changes, the default git diff action will be to not show those differences. See the http://git-scm.com/docs/git-diff man page DESCRIPTION which talks about this. The git status output (without -s) would help everyone see whether this was the case.

    Alternately, if you didn't expect changes, this could be an OS/filesystem problem. Please report your OS and filesystem information.

    0 讨论(0)
  • 2021-02-02 07:48

    Make sure that you're not actually within another git repository. And if for some reason above commands fails, try to run:

    git show HEAD
    
    0 讨论(0)
  • 2021-02-02 07:50

    use --no-pager flag with diff

    git --no-pager diff filepath/filename.extn
    
    0 讨论(0)
提交回复
热议问题