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?
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
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.
Related
Is there a way to move a large number of files in a Fossil repo?
Ideally, I'd be able to move them to a new directory, and Fossil would detect that and keep tracking them. fossil mv requires specifying the filenames individually. fossil add can be used to start tracking the files once they've been moved, but then I have to use fossil rm to delete the existing files one at a time. Neither of these is practical for more than a handful of files.
Fossil mv can take a directory as argument and it will move every files inside recursively. But the semantic is not exactly like the unix "mv" command and it doesn't works with the "--hard" option (probably a bug).
Example, if you have a directory "dir" and want to move it inside a new
directory "subdir", this will works.
$ mkdir subdir
$ mv dir subdir/
$ fossil mv dir subdir/dir
note: You have to use "subdir/dir" for the destination argument. Otherwise it will not do what you what, it will move all files that is inside dir directly in subdir. (so it doesn't use the same semantic as the unix "mv" command).
fossil addremove does this. It's the equivalent of fossil add . to add all new files, followed by fossil rm for each missing file.
Moving files is only one use for this command. You can also use it if you've deleted multiple files.
The downside is that moved files will be treated as new files, so you will have to keep that in mind when viewing the repo history.
Using .gitignore, is there a way to ignore a directory if it contains a certain file (or directory)?
This would be something like look-ahead assertions, though my use case is a little different: I want to ignore Mercurial repos in my project, to keep from accidentally committing them as part of the project. That is, I want to ignore all directories containing .hg, not just .hg itself.
I can work around this using the answer from this question, adding each directory name to .gitignore, but I'd like to make it more general if I can.
There is no way to do it beside adding all of them to your .gitignore file.
What you can do it to write a scipt which append all the desired paths to your .gitignore.
The content of .gitignore is alist of paths so git can be configured based upon content.
Each line in a gitignore file specifies a pattern
I'm using ag to search a git repo. It doesn't find matches under my node_modules subdirectory. Why not, and how can I control this behavior?
It turns out that ag honors the contents of the .gitignore file by default. So if node_modules is in .gitignore, ag won't search it. This is all sensible behavior, but difficult to debug if you aren't expecting it. Hopefully this post will help.
There's a good summary at the end of man ag:
IGNORING FILES
By default, ag will ignore files whose names match patterns in .gitig-
nore, .hgignore, or .agignore. These files can be anywhere in the
directories being searched. Ag also ignores files matched by the
svn:ignore property if svn --version is 1.6 or older. Finally, ag looks
in $HOME/.agignore for ignore patterns. Binary files are ignored by
default as well.
If you want to ignore .gitignore, .hgignore, and svn:ignore, but still
take .agignore into account, use -U.
Use the -t option to search all text files; -a to search all files; and
-u to search all, including hidden files.
For my purposes ag -t seems to work well.
I have read some of the questions and answers here, but it none match my situation exactly.
I want to keep all my fossil repos in a single place.
so I have
c:\Fossil_Repos\ with a repo for WebPages_Repo and another for Dev_repo etc etc etc
I would like to keep my original web pages and development pages in separated directories that are oustide of the Fossil_Repos directory, here is my structure
c:\Fossile_Repos\
c:\DevEnvironment\
c:\WebPageDevelopment\
This structure seems not to be unreasonable.
If from within my c:\Fossile_Repos\ I run the commands
fossil open Dev_Repo
fossil add c:\DevEnvironment
Then I see a listing of all the directories and files underneath c:\DevEnvironment, however I then go on to add
fossil commit -m "first deposit"
And get an error message on the first file saying the file doesn't exist. Note that the file path is correct (however it report the direcory as C:/DevEnvironment/firstFile.xml using the unix method of file separators)
Anyone got any thoughts on if I can do this or not?
thanks in advance
David
You can keep the repos wherever you like. However, you must issue the commands to fossil from inside the checkout.
So, in your example:
cd c:\DevEnvironment
fossil open c:\Fossile_Repos\repo_file_name
.. edit the files ...
fossil commit -m "first deposit"
I've done some research, but honestly can't seem to figure this out.
You can set some set some options to have fossil extras ignore files, but not fossil add? The configuration options through the web interface is great, and I'm pleased that it does work for the extras command, but it doesn't apply to the add command?
How does one configure fossil to ignore files on fossil add .?
You can use the settings ignore-glob command to list the directories/files to ignore as a comma-separated list.
On your repository's web interface, go to the Admin menu, select Settings and type the comma-separated list of directories to ignore; for example: */*.suo,*/*/bin/*,*/*/obj/*.
Alternatively, on the command line you can type fossil settings ignore-glob to list the applied ignore list, or fossil settings ignore-glob list-of-files.
You can also create/edit the .fossil-settings/ignore-glob at the root of the project and insert the comma-separated list of files/directories to ignore; I have not personally tested this, but I remember reading this online.
For example, on the command line you can do:
fossil settings ignore-glob "*/*.suo,*/*/bin/*,*/*/obj/*"
This would ignore all .suo files in every subdirectory at the Fossil repository root tree, and all the files in the bin and dir subdirectories at the each of the directory in the root directory.
If you want something like .gitignore or .hgignore, you can read https://www.fossil-scm.org/index.html/doc/tip/www/settings.wiki
mkdir .fossil-settings
echo '*/*.suo' >> .fossil-settings/ignore-glob
echo '*/*/bin/*' >> .fossil-settings/ignore-glob
fossil add .fossil-settings
See this check-in in fossil development repository. What you asked for has been implemented.
very recent versions of Fossil have an addremove command that will add all extras and remove all missing files in your working tree. The --ignore-glob switch is available.
Perhaps this is what you are looking for?
Otherwise you could probably just do :
fossil extras | xargs fossil add
On Windows 7 (not tested on other platforms)
If you do
fossil add *.*
All ignore-glob settings are ignored (all files are added).
If you do
fossil add .
then ignore-glob settings are used.
It is because I have already added the file, and fossil skipped the duplicated "add" operation, OMG.