'git diff' doesn't give any output

前端 未结 9 2143
迷失自我
迷失自我 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 10:04

    GIT DIFF DOESN'T WORK AFTER STASH

    Someone may run into this after attempting to apply stashed changes like I did.

    • Stash changes
    • Move to different branch and do some work
    • return to work-in-progress branch, update (git pull) then git stash apply (possibly with merge conflict)
    • git diff no longer works...

    At this point simply stash your changes again (git stash), do git pull to ensure everything is up to date (because I'm paranoid about it), double check that all files are up to date in working directory (possibly run rsync if dealing with remote/local), then attempt to git stash apply again and it should work!

    In answer to the original question, git diff isn't showing anything because you have a brand new directory, with a newly added file, but there are zero changes in the file for git diff to show. git status is showing that you added a new file, but git diff is for showing changes within files. If you made changes to the file, committed it, then made additional changes to it and ran git diff it would then show you the changes to the file.

提交回复
热议问题