#!/bin/sh# Script by Eli Delventhal# Creates Git projects for file folders by making the origin Dropbox. You will need to install Dropbox for this to work.
# Not enough parameters, show help.if [ $# -lt 1 ] ; then
cat<<HELPprojects_to_git.sh -- Takes a project folder and creates a Git repository for it on Dropbox
USAGE:./projects_to_git.sh file1 file2 ..
EXAMPLES:./projects_to_git.sh path/to/MyProjectDirCreates a git project called MyProjectDir on Dropbox
./projects_to_git.sh path/to/workspace/*Creates a git project on Dropbox for every folder contained within the workspace directory, where the project name matches the folder name
HELPexit 0fi
# We have enough parameters, so let's actually do this thing.
START_DIR=$(pwd)
# Make sure we have a connection to Dropboxcd ~if [ -s 'Dropbox' ] ; thenecho "Found Dropbox directory."cd Dropboxif [ -s 'git' ] ; thenecho " Dropbox Git directory found."elseecho " Dropbox Git directory created."mkdir gitfielseecho "You do not have a Dropbox folder at ~/Dropbox! Install Dropbox. Aborting..."exit 0fi
# Process all directories matching the passed parameters.echo "Starting processing for all files..."for PROJ in $*doif [ -d $PROJ ] ; thenPROJNAME=$(basename $PROJ)echo " Processing $PROJNAME..."
# Enable Git with this project.cd $PROJif [ -s '.git' ] ; thenecho " $PROJNAME is already a Git repository, ignoring..."elseecho " Initializing Git for $PROJNAME..."git init -qgit add .git commit -m "Initial creation of project." -q
# Make the origin Dropbox.
cd ~/Dropbox/gitif [ -s $PROJNAME ] ; thenecho " Warning! $PROJNAME already exists in Git! Ignoring..."elseecho " Putting $PROJNAME project on Dropbox..."mkdir $PROJNAMEcd $PROJNAMEgit init -q --barefi
# Link the project to the originecho " Copying local $PROJNAME to Dropbox..."cd $PROJgit remote add origin "~/Dropbox/git/$PROJNAME"git push -q origin mastergit branch --set-upstream master origin/masterfifidone
echo "Done processing all files."cd $START_DIR