代码之家  ›  专栏  ›  技术社区  ›  PlayHardGoPro

我可以列出当前提交的文件吗?

  •  8
  • PlayHardGoPro  · 技术社区  · 8 年前

    想象一下,每次我提交文件时,在推送文件之前,我都想列出要检查的文件。我该怎么做?

    git ls-tree -r --name-only master
    git ls-files -stage
    

    如果我编辑一个文件, add 然后 commit 它如果我尝试以上代码,它会显示我的所有文件。

    3 回复  |  直到 8 年前
        1
  •  18
  •   LightBender    8 年前

    Git在这件事上有分歧。您将使用 --name-only

    #before stage
      git diff --name-only 
    #staged changes before committing
      git diff --name-only --cached
    #after committing
      git diff --name-only HEAD^ HEAD
    

    如果要查看在有多个提交时要推送的文件,则需要指定当前分支头和远程分支头

    git diff --name-only remote/branch branch
    
        2
  •  6
  •   xvf    8 年前

    如果要列出上次提交(本地或非本地)中的文件,请使用

    git show --name-only
    
        3
  •  1
  •   Community Mohan Dere    5 年前

    正如您在推送之前所说的,我可以假设您的工作流程是git add然后git commit然后git push吗。

    link !

    git commit --short -m "message for the commit"

    enter image description here