Global Ignores on Subversion(feat. Unreal)
Sadly, ignoring files in SVN is not as convenient as in git. Whether by legacy reasons or by design, it is what it is.
So how can we close emulate git's .gitignore functionality in SVN?
When looking up the internet, the provided answers are not clear cut as you might think. Ignoring files and directories requires adding a "property" to files and folders, and here is the catch, the top suggestions have their caveats.
client-side only solutions like editing subversion config settings or the global ignore pattern in TortoiseSVN are clearly not the way to go, as we want to keep the ignore information in the repo.
Majority of answers will mention the svn:ignore property but this has big drawbacks like having to checkout the repo again and adding it again whenever you create a new directory. The usage of the --recursive flag also does not work as you might expect, as your property values cannot be actual paths.
The correct choice is using the svn:global-ignores property, which was added in Subversion 1.8, but search results in the internet will point you to 1.7 documentation more often than not for some reason. Even ChatGPT will suggest you the regular ignore property first.
So here's is my setup for Unreal, for example, as it generates a lot of intermediate files that you'll want to ignore.
On the project root, create a ".svnglobalignore" text file. Add these lines to it:
Developers DerivedDataCache Intermediate Platforms Autosaves Crashes Logs ShaderDebugInfo SourceControl webcache_4430 AutoScreenshot* CrashReportClient WorldState ConsoleHistory* Editor.ini EditorPerProjectUserSettings* GameUserSettings*
2. On Windows, right click on an empty spot on the root folder and select "Open Powershell here". Paste this line on the Terminal:
svn propset svn:global-ignores -F .svnglobalignore .
Note the dot(.) at the end of the expression, representing the current folder. This translates to "In this current folder, add the global-ignores property and fill it with values from the .svnglobalignore file."
Again, because you can't add paths, nested folders like CrashReportClient are added as is, and the property will recursively ignore it if finds that folder or file down the line. Commiting the .svnglobalignore is optional, but I like to add it to the repo as I can just add new values to it and re-run the command as needed.
One of the downsides of not being able to add paths is that depending of your project structure you'll still need to add some svn:ignore property in some directories. For example, in Unreal you have the following paths(/ being the project root):
/Content/Collections
/Saved/Collections
"Collections" being like assets you categorize together for some reason, like favorites. You'll want to commit the Content/Collections path, because this will be shared with the rest of your team. But the Saved/Collections is intended to be local-only, for your personal use, so there's no need to be stored in a repository. If you add the "Collections" to the .svnglobalignore file it will ignore both. The work around I use is adding a .svnignore text inside the /Saved/ path and adding the line:
Collections
Then run the line in Powershell(Run it inside the /Saved/ folder):
svn propset svn:ignore -F .svnignore .
This will ignore the local collections folder, then you can also commit the .svnignore file.
So there you have it. A lot of hoops were jumped in the process of learning this way of working but things behave predictably with it. Adapt the values of .svnglobalignore to your needs and think about the naming of your paths so you don't end with the "Collections" clash mentioned above.
See you next mission.