How to keep SVN from updating a directory already in repository

假装没事ソ 提交于 2019-11-29 03:40:01

I went with the sparse checkout route similar to what Stefan mentioned. The difference is I excluded a whole directory.

Here's what I did to exclude a whole directory and all its subdirectories. Note: the unwanted directory was already on my disk so I deleted it first.

$ rm -rf unwanted-directory
$ svn checkout url/to/repo/unwanted-directory unwanted-directory --depth empty
$ cd root/of/my/tree
$ svn update
<- unwanted-directory is not acquired from the repository

For reference, we have a 'prototype' directory in our tree with a bunch of experimental code. Since I don't work in this area, I have no interest in having the 1G to sources in my multiple development trees.

You can do a sparse checkout:

svn co url/to/repo mywc --depth=files

that will get you a wc with only the files in it, no subfolders. You can now get all the folders you want with

svn up url/to/repo/subfolder1 --set-depth infinity 
svn up url/to/repo/subfolder2 --set-depth infinity 
svn up url/to/repo/subfolder3 --set-depth infinity 
...

You could use a script to svn update --non-recursive the current directory, then individually update the remaining subdirectories recurvively. With a bash script you could loop over all the subdirectories and just skip over the offending one.

Something like this:

#!/bin/bash

BADDIR="bad"
FILELIST="*"

svn update --non-recursive

for file in $FILELIST
do
if [ -d $file ]
then
   if [ $file != $BADDIR ] 
   then
     svn update $file
   fi
fi
done

If you rename the .svn directory in the bad folder and then run an update, svn will skip over the directory and say it was deleted even though it's still there.

You will need to put it back though when you want to commit, at least at an upper level which contains the bad directory.

Update all current location data except some bad directory :

svn up `svn ls | grep -v badDirectory`

You could specify --non-recursive or -N to suppress it from getting all the subdirs

and the explicitly do an update on the ones that you want.

A small batch file would make it easily repeatble

\0

If it's not a necessary folder for day to day work for you (or your group) you could ask the administrator to update the svn hierarchy to move that folder at the same level (or higher) than the folders you have to update.

for example

projet - non-essential folder 
       \ essential folder

and you will only have to update (check-out) the "essential folder" and the others will also have to update (check-out) the "non-essential folder".

Solutions already provided, I'd say that the need to ignore one part of the repository on a regular basis is a clear sign of bad repository structure. Try to find a way to move it to a different location inside repository or something like that.

Kirby's solution is clean except that it doesn't update the current directory.

If you have a structure like this:

root -
     |-subdir1
     |-subdir2
     |-fileA
     |-fileB

Kirby's solution won't update fileA, fileB and any other files that are later added to the root dir.

You'll want to add a "svn up -N". You could do this with an alias and a semicolon:

alias myup='ls | args svn up; svn up -N'

(That's bash alias syntax. If you're using a different shell, alter as needed)

Use the following command

find -maxdepth 1 ! -name . ! -name .svn ! -name badDirectory -exec svn up {} \;

Keep appending all the directories before -exec like ! -name directoryname

find -maxdepth 1 ! -name . ! -name .svn ! -name badDirectory ! -name badDirectory2 ! -name badDirectory3 -exec svn up {} \;

Whilst considering vendor-specific solution, in TortoiseSVN you can achieve it by following the procedures described on the manual page, after the listing inside the section "Checkout Depth".

If you check out a sparse working copy (i.e., by choosing something other than fully recursive for the checkout depth), you can fetch additional sub-folders later by using the repository browser (the section called “The Repository Browser”) or the check for modifications dialog (the section called “Local and Remote Status”).

In windows explorer, Right click on the checked out folder, then use TortoiseSVN → Repo-Browser to bring up the repository browser. Find the sub-folder you would like to add to your working copy, then use Context Menu → Update item to revision....

BUT: I'd like to add that I'd change the final step. Instead of finding the sub-folder you'd like to add (or remove) from the working copy, right click on the root folder, choose "Update item to revision...", on Working Depth click on button "Choose Items" and select all the childs on the file manager that opens.

I see the question was asked quite some time back, but if you are still interested, I stumbled upon a nice blog that explains different ways of using "svn:ignore"

Here is the link : http://superchlorine.com/2013/08/getting-svn-to-ignore-files-and-directories/

As explained in the blog, you could probably create a list of "bad folders" in a file and use "svn propset svn:ignore -R-F bad_folder_list_file"

Hope that helps !

So I just came up with what I think is about the fastest answer to the question. Since SVN doesn't have a way to autoignore directories that I don't want updated...

Here's my existing dir structure:

root -> goodDir 1 -> goodDir 2 etc

I've deleted the bad directories from my checkout. I can't do an 'svn up' from the root directory, because it tries to recheck out the bad directories.

But, the following command works nicely:

  ls | xargs svn up

Short, sweet, simple, and easy to remember.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!