Skip to content

Instantly share code, notes, and snippets.

@yamatt
Created November 22, 2021 09:43
Show Gist options
  • Save yamatt/a9de791a6ff0e8ea4c4f41e51e4295c7 to your computer and use it in GitHub Desktop.
Save yamatt/a9de791a6ff0e8ea4c4f41e51e4295c7 to your computer and use it in GitHub Desktop.
Run command against changed files in branch
# When using a feature branching model against the main branch this will allow you to iterate over
# all the files that have changed compared to branch and run a command against each of them.
for file_path in $(git diff --name-only origin/main | grep '^content/'); do
echo "$file_path"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment