SVN checkout ignore folder

2019-01-08 04:00发布

Can I ignore a folder on svn checkout? I need to ignore DOCs folder on checkout at my build server.

edit: Ignore externals isn't an option. I have some externals that I need.

10条回答
我命由我不由天
2楼-- · 2019-01-08 04:12

You can't directly ignore folders on a checkout, but you can use sparse checkouts in svn 1.5. For example:

$ svn co http://subversion/project/trunk my_checkout --depth immediates

This will check files and directories from your project trunk into 'my_checkout', but not recurse into those directories. Eg:

$ cd my_checkout && ls
bar/ baz foo xyzzy/

Then to get the contents of 'bar' down:

$ cd bar && svn update --set-depth infinity
查看更多
贼婆χ
3楼-- · 2019-01-08 04:19

Yes you can using SVN 1.6. You will need to do a checkout first then mark the folder for exclusion then delete the unwanted folder.

svn checkout http://www.example.com/project
cd project
svn update --set-depth=exclude docs
rm -fr docs

From now on any updates to the working copy won't repopulate the docs folder.

See http://blogs.collab.net/subversion/2009/03/sparse-directories-now-with-exclusion/ and http://subversion.apache.org/docs/release-notes/1.6.html#sparse-directory-exclusion for more details.

Tom

查看更多
【Aperson】
4楼-- · 2019-01-08 04:21

As a few others have mentioned, you can just use svn:externals properties and then the --ignore-externals option when you checkout. One thing to note, however, is that svn:externals does not necessarily need to refer to another repository. It can be a reference to some other folder in the same repo.

查看更多
叼着烟拽天下
5楼-- · 2019-01-08 04:22

I found this question looking for a way to check out the WebKit sources while excluding the regression tests. I ended up with the following:

svn checkout http://svn.webkit.org/repository/webkit/trunk WebKit \
  --depth immediates

cd WebKit
find . \
  -maxdepth 1 -type d \
  -not -name '.*' \
  -not -name '*Tests' \
  -not -name 'Examples' \
  -not -name 'Websites' \
  | (while read SUBDIR; do svn update --set-depth infinity "$SUBDIR"; done)

Note you can change the exclusions as you see fit, but .* is recommended to skip the working directory (which is already up to date) and all of the .svn directories.

查看更多
手持菜刀,她持情操
6楼-- · 2019-01-08 04:23

Yes, Subversion 1.5 has a feature called Sparse checkouts that can do exactly this sort of thing.

查看更多
Summer. ? 凉城
7楼-- · 2019-01-08 04:26

I have recently resolved the same task. The idea is to get the immediate list of folder/files under the repository exclude the entries you need, then check out the remaining folders and update the immediate files if any. Here is the solution:

    # Path to the svn repository to be checked out
rpath=https://svn-repo.company.com/sw/trunk/ && \
    # This files are to be excluded (folders are ending with '/')
    # this is a regex pattern with OR ('|') between enties to be excluded
excludep='docs_folder/tests_folder/|huge_folder/|file1|file2' && \
    # Get list of the files/folders right under the repository path
filtered=`svn ls $rpath | egrep -v $excludep` && \
    # Get list of files out of filtered - they need to be 'uped'
files=`echo $filtered | sed 's| |\n|g' | egrep '^.*[^/]$'` && \
    # Get list of folders out of filtered - they need to be 'coed'
folders=`echo $filtered | sed 's| |\n|g' | egrep '^.*[/]$'` && \
    # Initial nonrecursive checkout of repository - just empty
    # to the current (./) working directory
svn co $rpath ./ --depth empty && \
    # Update the files
svn up $files &&\
    # Check out the all other folders finally.
svn co `echo $folders | sed "s|\<|$rpath|g"`

Change to source working directory. Copy the commands. Paste. Change appropriate URL and exclude pattern. Run the command.

Thanks,

查看更多
登录 后发表回答