0

In git, if a new folder is not staged, git status will only print folder name as following:

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        new-folder/

But once it was staged, git status will print the new folder this way:

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        new file:   new-folder/new-file-1
        new file:   new-folder/new-file-2
        new file:   new-folder/new-file-3
        new file:   new-folder/new-file-4
        ...
        new file:   new-folder/new-file-199
        new file:   new-folder/new-file-200

It there a way to get a list of staged changes but only folder names for staged new folders?

I'm writing a script to get a list of modified/added/deleted files before commit, by means of git status --porcelain. In the above case, the list will be too long.

phd
  • 82,685
  • 13
  • 120
  • 165
lzhh
  • 852
  • 7
  • 16

1 Answers1

0
git diff-tree @ `git write-tree`

is a pretty good starting point, with whatever formatting options you want like name-status and diff-filter.

jthill
  • 55,082
  • 5
  • 77
  • 137