How can I run “git status” and just get the filenames

后端 未结 9 1511
遥遥无期
遥遥无期 2020-12-04 14:23

as opposed to the long relative path?

相关标签:
9条回答
  • 2020-12-04 14:47

    In addition to the accepted answer, another way of doing it is with awk

    git status --porcelain | awk '{ print $2 }'
    

    The $2 selects second the column of each line.

    0 讨论(0)
  • 2020-12-04 14:55

    git status will always walk down (edit and up) the tree and display relative paths. If you only want the file in the directory you are in, See this related answer

    0 讨论(0)
  • 2020-12-04 14:56

    Aha, I think I just understood the question: you want basenames? Tack on | while read a; do basename "$a"; done to any of the following:

    how about

    • git diff --name-only

      for changes relative to index

    • git diff --name-only --staged

      for ... well staged chages :)

    • git diff --name-only HEAD

      got both

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