Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sansumbrella/108398 to your computer and use it in GitHub Desktop.
Save sansumbrella/108398 to your computer and use it in GitHub Desktop.
Bash script to create and initialize a git repo on a dreamhost server
#Based on:
#http://casperfabricius.com/site/2008/09/21/keeping-git-repositories-on-dreamhost-using-ssh/
DREAMGIT_DOMAIN=you@yourhost.dreamhost.com
GIT_DOMAIN=whatever.you.want
DH_USER=home/yourusername
YEAR=`eval date +%Y`
#set up on the server
ssh $DREAMGIT_DOMAIN 'mkdir -p '$GIT_DOMAIN'/'$YEAR'/'$1'.git && cd '$GIT_DOMAIN'/'$YEAR'/'$1'.git && git --bare init'
#set up locally
mkdir $1
cd $1
git init
#associate with server
git remote add origin ssh://$DREAMGIT_DOMAIN/$DH_USER/$GIT_DOMAIN/$YEAR/$1.git
#get some default folder contents
cp -r /usr/local/bin/git_defaults/* ./
mv gitignore .gitignore
echo $1 >> README
git add .
git commit -m 'Created new repo'
git push origin master
echo "
[branch \"master\"]
remote = origin
merge = refs/heads/master" >>.git/config
echo "Your new git repo '$1' should be all set up at $DREAMGIT_DOMAIN/$GIT_DOMAIN/$YEAR/$1.git"
@leonardofaria
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment