Skip to content

Instantly share code, notes, and snippets.

@jkubicek
Created May 22, 2010 12:49
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jkubicek/410050 to your computer and use it in GitHub Desktop.
Save jkubicek/410050 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Create Git Repository
# created by Jim Kubicek, 2009
# jimkubicek@gmail.com
# http://jimkubicek.com
# DESCRIPTION
# Create remote git repository from existing project
# this script needs to be run from within the project directory
# This script has been created on OS X, so YMMV
#######
# Parameters
REPLOGIN=#Login name
REPADDRESS=#Repo address
REPLOCATION=/Users/Shared/Development #Repo location
# The repo name defaults to the name of the current directory.
# This regex will accept foldernames with letters and a period.
# You'll have to edit it if you've got anything else in your folder names.
REPNAME=`pwd | egrep -o "/[a-zA-Z]+$" | egrep -o "[a-zA-Z\.]+"`
# If you have standard files/directories to be ignored
# add them here
echo "Creating .gitignore"
echo 'build/' >> .gitignore # The build directory should be ignored for Xcode projs
echo '.DS_Store' >> .gitignore # A good idea on OS X
# Create the git repo
echo "Initializing the repo"
git init
git add .
git commit -m "Initial commit"
# Copy the repo to the server
echo "Copying the git repo to the server $REPADDRESS"
TEMPREP="$REPNAME.git"
git clone --bare .git $TEMPREP
scp -r $TEMPREP $REPLOGIN@$REPADDRESS:$REPLOCATION/
rm -rf $TEMPREP
# Set up the origin for the project
echo "Linking current repository to remote repository"
git remote add origin $REPLOGIN@$REPADDRESS:$REPLOCATION/$REPNAME.git/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment