I need a list of files that changed and dump it to the files
I can get all the list by running this
git diff-tree --name-status -r "upstream/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME..HEAD" > changed-files.txt
But now I want only a list of files that changed inside the resources folder only
How to do that?
You can target a subdirectory within a commit using the following syntax :
<commit hash or name>:path/to/dir
In your case, you can change your git diff-tree command to :
git diff-tree --name-status -t \
"upstream/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME":resources \
HEAD:resources
As @torek comented, you can also simply provide a path after the compared elements, to narrow the diff to that path only, so the following command also works :
git diff-tree "upstream/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" HEAD -- resources
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With