开发者

how to remove .svn folder from github repo

开发者 https://www.devze.com 2023-03-25 00:33 出处:网络
I have pulled a repository using TortoiseSVN. In it are .svn folders in the root and all subfolders. I have created a github repository and pushed whole repository.

I have pulled a repository using TortoiseSVN. In it are .svn folders in the root and all subfolders. I have created a github repository and pushed whole repository.

The problem is that in my local copy I have deleted the .svn folders from repo and then commited the changes. It doesn't remove the folder from previous versions of repository...

I know how to remove sensitive data from github repo from here:

http://help.github.com/remove-sensitive-data/

But if I use this I have to follow this procedure more than 10 time (and it's such a waste of time to do that) ... so I was wondering that anyone can tell me how开发者_C百科 to delete all .svn folders from the whole repo in a single go?


I needed to do this recently and I just ran the following command from my root directory of my repo:

 find . -name '.svn' | xargs git rm -rf --ignore-unmatch

This searches recursively for all occurrences of the .svn folder and removes it and its contents recursively. the --ignore-unmatch parameter prevents git from choking if it does not find the specified file in the repository.

The next thing to do, of course, is to add .svn to your .gitnore so that you don't mistakenly start tracking those files ever again.


Try this:

find . -type d -name .svn | xargs git rm -rf --ignore-unmatch


I recently had to do this on my windows machine. Here's the comparable PowerShell command. there's probably a better way, but I'm pretty clumsy with PS:

gci -Recurse -filter ".svn" | ?{ $_.PSIsContainer } | Select-Object FullName | %{ git rm -rf --ignore-unmatch $_.FullName }

GCI (Get-Child-Item) will find all the things named ".svn", the PSIsContainer checks if its a directory, Select-Object is supposed to get out just the FullName attribute, and then the git rm -rf command is placed inside a foreach loop.

0

精彩评论

暂无评论...
验证码 换一张
取 消