0

I have about 10 extensions that I want to add to the index with a script in my CI pipeline.

I know that git add supports file patterns such as *.c (the term used in the documentation is 'fileglob').

However, is there a way to add multiple extensions with a single command, e.g. git add *.{dll,exe,json}?

I have not found any examples in the documentation or Stack overflow about this issue.

5
  • The syntax *.{dll,exe,json} is from bash. So if you use git-bash you can use the synax. In cmd just list extensions one by one: git add *.dll *.exe *.json Commented Dec 2, 2022 at 12:12
  • 1
    Their CI almost certainly doesn't run Git Bash, but it's enough if they have Bash. However, it's quite possible that the automation only supports POSIX sh, in which case like you say they need to enumerate the wildcards separately. See also Difference between sh and bash Commented Dec 2, 2022 at 12:19
  • My CI is an Azure Pipelines agent, that runs a Powershell script in a Windows Machine. Apologies, I should have clarified that. Commented Dec 2, 2022 at 14:42
  • I added the powershell tag, but you might want to update the question text itself to be specific about powershell here. Commented Dec 2, 2022 at 20:16
  • According to Microsoft's page you can run agents on any system you like, so it's difficult for anyone to guess how your agent, whatever it might be, uses whatever string Microsoft's UI passes to it. Git commands do accept multiple patterns; if you tried specifying them then the UI or the agent are passing them explicitly marked as a single pattern with embedded spaces. Yuck, and my sympathies, but you're going to have to say what specific tools you're using that might be doing this. Commented Dec 2, 2022 at 20:41

1 Answer 1

0

In powershell this should be something like the following if you want to add files recursively:

Get-ChildItem -Recurse -Filter "*.dll" -or -Filter "*.exe" -or -Filter "*.json" | ForEach-Object { git add $_ }

(extend to your 10 extensions)

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.