Home > Blockchain >  How to show only filenames with "git status"?
How to show only filenames with "git status"?

Time:09-12

How do I show only filenames for all modified files in my repository? git status adds additional output, e.g.,

$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
  (commit or discard the untracked or modified content in submodules)
    modified:   my-file (modified content)

How do I get:

$ git status --name-only   # --name-only is not a valid option; what do I use instead?
my-file

CodePudding user response:

There's an output option which does pretty much what you asked.

Only paths, with a letter to indicate A(dded), (M)odified, and so on.

git status -s [-b]

CodePudding user response:

Instead of git status, use git diff, e.g.,

$ # Show modified files, and only the filenames
$ git diff --name-only --diff-filter=u
my-file
  • Related