May I list the files of the current commit?

后端 未结 3 1936
醉梦人生
醉梦人生 2021-02-09 18:27

Imagine that everytime I commit files, before I push them, I\'d like to list them to check. How may I do that ?

I tried:

git ls-tree -r --name-only m         


        
相关标签:
3条回答
  • 2021-02-09 18:49

    If you want to list files in the last commit (local or not), use this

    git show --name-only
    
    0 讨论(0)
  • 2021-02-09 18:52

    Git diff to the rescue on this one. You'll use the --name-only flag. To get the contents of the current commit, use this command:

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

    If you want to see the files that you will be pushing if there is more than one commit, you'll need to specify your current branch head and the head on the remote

    git diff --name-only remote/branch branch
    
    0 讨论(0)
  • 2021-02-09 18:55

    As you say before the push, can i supposing that your work flow is git add then git commit then git push.

    You can do the commit with the --short option link!

    This will give you a output of all files change, add or delete in your that currently commit.

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

    0 讨论(0)
提交回复
热议问题