Skip to content

Instantly share code, notes, and snippets.

@kogakure
Created June 25, 2009 15:33
Show Gist options
  • Select an option

  • Save kogakure/135926 to your computer and use it in GitHub Desktop.

Select an option

Save kogakure/135926 to your computer and use it in GitHub Desktop.
Bash: Convert folders recursively to git repos
#!/bin/bash
# Convert folders recursively to git repos
# Run it in the folder that holds all your project folders
for i in $( ls -d */ ); do
string=$i
length=${#string}
project=${string:0:$length-1}
cd $project
junkdel # Special script to delete all junk files
git init
git add .
git commit -m "Initial commit"
git clone --bare -l .git ../$project.git
cd ..
cd $project.git
touch git-daemon-export-ok
touch GITWEB_EXPORT_OK
echo $project > description
git --bare update-server-info
chmod a+x hooks/post-update
git gc
cd ..
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment