1

As title, I have several types of file stored in a folder (with sub-folders) that I use Fossil to keep a repository (e.g. foo.R; foo.xls; foo.csv), I only want my R files to be added into the repository. I only know using fossil add . to add all the files, and then use fossil delete *.csv to remove the files I don't need.

Is there a more efficient way?

lokheart
  • 23,743
  • 39
  • 98
  • 169

2 Answers2

4

In addition to Reimer Behrends’ answer: on the Windows command line, you can use the recursive for loop:

for /r . %F in (*.r) do @fossil add %F

to add all your .r files to the repository, including those in subfolders. (If your files are all in the same folder, fossil add *.r will do).

Note that if you want to use this in a batch or .cmd file, you'll have to double the percentage characters (%%):

for /r . %%F in (*.r) do fossil add %%F
Martijn
  • 13,225
  • 3
  • 48
  • 58
2

There is no direct way to whitelist certain extensions, but there is a way to blacklist ones you don't need. This can be done via the fossil settings command, which can also be abbreviated as fossil set. For example, to exclude .xls and .csv files, you can do:

fossil set ignore-glob '*.xls,*.csv'

The ignore-glob setting is a variable that will accept a comma- or newline-separated list of glob patterns. These will be ignored by fossil add, fossil addremove, fossil clean and fossil extra. You can use fossil set ignore-glob to query the current value of this variable.

The alternative (which allows for whitelisting) is to explicitly specify the files that you are adding. For example, if you're on Unix, you can do something like:

fossil add $(find . -name '*.R')

to only add the files that you need. For some shells, fossil add **/*.R may also work, and if you don't have any subdirectories, fossil add *.R should work anywhere.

Reimer Behrends
  • 8,600
  • 15
  • 19