Skip to content

Instantly share code, notes, and snippets.

@charliefulton
Created June 27, 2013 11:54
Show Gist options
  • Save charliefulton/5875879 to your computer and use it in GitHub Desktop.
Save charliefulton/5875879 to your computer and use it in GitHub Desktop.
#!/bin/bash
# author: charlie_fulton@me.com
#
# If the current directory is a git project then this script will make a bare clone
# of it into the directory specified (most likely a network based directory) e.g. a shared Dropbox folder.
#
# The idea is to have a place to push / pull changes from that is shared with another developer.
# see idea from: http://www.cimgf.com/2008/06/03/version-control-makes-you-a-better-programmer/
#
export DROPBOX_DIR=$2
# first arg is name of git project shared
export PROJECT_NAME=$1
# make sure we have one argument
if [ $# -ne 2 ]; then
echo "error no project name and directoy specified. usage: sharegitproject <name of project> <directory>"
elif [ ! -d .git ]; then
echo "Sorry, current directory must be a git project."
else
# create a clone of the current project with --bare which will just
# be the .git repo (all files, etc. necessary)
if [ -d "$DROPBOX_DIR" ]; then
git clone --bare . $DROPBOX_DIR/$PROJECT_NAME.git
git remote add sharedproject $DROPBOX_DIR/$PROJECT_NAME.git
echo "you can now push changes to this sharedproject location"
echo "e.g. git push sharedproject master"
else
$DROPBOX_DIR does not exist, could not clone project.
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment