Reputation: 89
I am trying to figure out what is the git command to get all the folders with changes in them.
git diff --name-only
But this gives all the actual files that changed?
Upvotes: 2
Views: 321
Reputation: 3769
To get the paths containing changes, pipe the output through xargs
to dirname
git diff --name-only | xargs dirname | uniq
This will strip all the filenames from the relative paths and remove any duplicates.
For example:
$ git diff --name-only
app/lib/sub/dirlist.cpp
app/net/rpc.cpp
config/config.txt
after dirname
will return
$ git diff --name-only | xargs dirname | uniq
app/lib/sub
app/net
config
xargs
takes multiple lines (list outputs) and runs the following command (dirname
in this example) on each in turn. uniq
will remove duplicates from the output.
Upvotes: 4