Web Niraj
  • Facebook
  • Flickr
  • Github
  • Instagram
  • Linkedin
  • Twitter
  • YouTube
Online portfolio, code examples and developer blog
  • About
  • Contact
  • Portfolio
  • WordPress
Search the site...
  • Home
  • Blog
  • Finding and Deleting .svn / .git Subdirectories from Application Directories

Finding and Deleting .svn / .git Subdirectories from Application Directories

0

If you’re like me in reusing entire application code bases to create new apps, you will run into this issue often: deleting .svn or .git directories from old applications so you can commit them to a new repository. Luckily, there are two easy command lines you can use to achieve this for either svn or git downloaded source code.

The Command Lines

You can use the below command lines to find .svn / .git folders in the current sub-directory, and then delete them so you can commit them to a new repository.

# === SVN === #
# find .svn folders in current directory
find . -name .svn -exec echo {} \;
# delete .svn folders in current directory
find . -name .svn -exec rm -rfv {} \;
# === GIT === #
# find .git folders in current directory
find . -name .git -exec echo {} \;
# delete .git folders in current directory
find . -name .git -exec rm -rfv {} \;
view raw find_and_delete.sh hosted with ❤ by GitHub

The command lines can also work for other directories. You can replace the find . -name with find /path/to/directory -name, and achieve the same result for a different directory.

Similarly, the code can also work for other folder types or files. You can replace the .svn or .git in the command line with a name of your choice. For example, you can replace .svn with *.php to find all PHP files in a given directory.

Examples:

# Find PHP files in current directory
find . -name *.php -exec echo {} \;
# Find annoying .DS_Store files in current directory (Mac issue)
find . -name .DS_Store -exec echo {} \;
# Find log files in current directory (ending in.log)
find . -name *.log -exec echo {} \;
view raw find_php.sh hosted with ❤ by GitHub
Command Line, Git, Subversion, Version Control

Leave a Reply Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

StackExchange / StackOverflow

profile for Niraj Shah on Stack Exchange, a network of free, community-driven Q&A sites

Subscribe for updates

Support Me

Buy Me a Coffee

PSN Profile

Tags

ACL Amazon Web Services Android Android 4.4 KitKat Android 5.0 Lollipop Apache Backup Bug Command Line Cordova cPanel / WHM Facebook Facebook Graph API Facebook PHP SDK 4.0 Facebook Social Plugins Fan Page Flash Flat File Geolocation Google Nexus 5 Hacking HTML5 iOS JavaScript jQuery Laravel 5 Linux Mac OS MongoDB NodeJS Parse PDF PHP Plugin Portfolio PS4 Review Security Server SSH SSL Sysadmin Tutorial WordPress WordPress Plugins

© 2011-2026 Niraj Shah
  • Blog
  • Portfolio
  • WordPress
  • About Me
  • Contact Me
  • Privacy Policy