Can I use git diff on untracked files?

前端 未结 10 1110
你的背包
你的背包 2020-11-27 09:58

Is it possible to ask git diff to include untracked files in its diff output, or is my best bet to use git add on the newly created files and the e

10条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-27 10:43

    this works for me:

    git add my_file.txt
    git diff --cached my_file.txt
    git reset my_file.txt
    

    Last step is optional, it will leave the file in the previous state (untracked)

    useful if you are creating a patch too:

      git diff --cached my_file.txt > my_file-patch.patch
    

提交回复
热议问题