In Git, if I have a project with lots of projects inside, let's suppose, a lot of Java projects, I can just create a .gitignore
file in the root and it will "be respected" in the entire repository.
How can I do this for an SVN project?
For example, how can I make an "svn ignore" setup (via cmd line) for a .gitignore
like the following?
*.class *.jar *.war *.ear target/ .classpath .settings/ .project .metadata bin/
The most important part of the question: How can I make it work to new folders inside the root? Example:
I ran svn propset svn:ignore "*.class" . -R
in my root and commit. Ok:
root - folder1/ -- *.class (ignored) -- other files (ok) - folder2/ -- *.class (ignored) -- other files (ok)
Now, I create folder 3. The previous svn:ignore
settings will not apply, right? Is there a way to make it so?
If you want to ignore a file that you've committed in the past, you'll need to delete the file from your repository and then add a . gitignore rule for it. Using the --cached option with git rm means that the file will be deleted from your repository, but will remain in your working directory as an ignored file.
You could add bin folder to ignore list. Right click on the bin folder -> TortoiseSVN -> Unversion and add to ignore list -> bin.
gitignore should list the names or name-patterns of files that will be found in work-trees when working with your project, but that should not be committed to the project. In other words, it's not OS-specific, it's project-specific.
You can use svn:ignore
. You generally need to tell SVN to apply special properties to the files:
svn propset svn:ignore "*.jpg" .
(Note the dot at the end of the command.)
For multiple files you can add a newline character.
Type exactly like here with line breaks:
svn propset svn:ignore "file1 file2 file3" dir1
Check that the files are ignored:
svn status --no-ignore
Then commit the code.
And yes, many duplicate questions are already available.
You can refer my favorite svn cheatguide.
You can create a file, svn-ignore.txt
, with your ignored files and directories:
*.class *.jar *.war *.ear target/ .classpath .settings/ .project .metadata bin/
Now try the following:
svn propset svn:ignore -RF /root/svn-ignore.txt . [dot for current dir]
-R
is for recursive.
This is what I am doing to emulate .svnignore
.
Create a wrapper for svn
called ~/bin/svn
#!/bin/bash case "$1" in commit|status|apply-ignore) if test -f .svnignore ; then echo "Apply .svnignore: $(/usr/bin/svn propset svn:ignore -F .svnignore .)" fi ;; esac case "$1" in apply-ignore) ;; *) exec /usr/bin/svn "$@" ;; esac
Then add ~/bin
to your path before /usr/bin
PATH=~/bin:$PATH ; export PATH
It applies .svnignore
on commit
and status
commands, and can also manually apply using svn apply-ignore
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With