Commit all modified/added files via the command line with Subversion excluding a provided black list
Solution 1
There is no option to ignore files on-the-fly on commit. However, there are two approaches you can take:
-
Use the changelists feature. This can help you create filters for the files that you do want to commit and only commit those. As changelists are created on the developer machine, your filters won't impact the general repository. For example, you can add all the files to a changelist using:
svn changelist to-commit *
And then remove those that you want to ignore:
svn changelist --remove /path/to/file1.php
Only
svn add
the files that you are working on, one by one as soon as you start editing one. Any file that has not beensvn add
ed to the repository will be ignored on commit. Of course, this comes with the disadvantage that you will be the only developer that will have those files on his machine.
Solution 2
I had a similar situation where in I had to commit only certain files from a bunch of modified files. I had to update/remove a dependency from a parent and all of its child projects (Maven) and commit the corresponding changes. Here is what I did to create the SVN changelist.
svn cl my-changelist $(svn st | grep '^M' | awk '{print $2}' | grep 'pom.xml')
svn commit -m "Updated dependencies" --changelist my-changelist
The first command above creates a changelist with name 'my-changelist' and adds all the modified files with name 'pom.xml' to the list.
The second command commits the changelist (all the files in the list against a single revision number).
crmpicco
Senior Analyst Developer (MoodleCloud) at Moodle, AWS Solutions Architect (Associate), Zend Certified Engineer and Google Analytics Qualified Individual
Updated on July 09, 2022Comments
-
crmpicco almost 2 years
I am investigating a way to commit all modified/added files via the command line with Subversion, excluding a provided black list. Is this possible?
If I have, say, 100 files I would like to commit, but interspersed with that list are seven files that I don't want to commit. Is there a way to say "commit all files excluding /path/to/file1.php, /path/to/file2.php, /path/to/file3.php", etc....
For example, I would have to do something like:
svn ci [list all files to commit in here] -m 'my commit message'
However, is there a better way to do it? I can't find anything documented regarding it.
-
crmpicco over 11 yearsThe issue here is that I don't want to ignore those files forever, and I don't want to forget about them. It's like that i'll make my commit of my 90-odd files and then make some more changes to the other 7 then make a commit later that day or the following day. Applying an
svn:ignore
will ignore these files until told otherwise, AFAIK. -
Lazy Badger over 11 yearsBetter will be to use
--targets ARG : pass contents of file ARG as additional args
on creating changelist stage -
Victor Stanciu over 11 yearsI guess that depends on the ratio between the number of files he wants to add vs the ones he want to exclude. Seeing how he only wants to exclude ~7 files out of ~100, I find it easier to add all of them to the changelist and then manually remove only the few that need to be ignored.
-
Lazy Badger over 11 yearsYes, it depends, but for long lists file-source is just manageable, from my POV
-
crmpicco over 11 yearsThanks, this is an interesting feature that I was not aware of. I'm sure it will come in use to me in the future. So, it would seem there is no way to create a blacklist or exclude list when performing an on-the-fly commit - that's a shame.
-
crmpicco over 11 yearsI'll accept your answer @VictorStanciu as it would appear there is no way to create a on-the-fly blacklist, certainly at this moment in time.