Skip to content

Instantly share code, notes, and snippets.

@digitalronin
Created November 4, 2009 11:23
Show Gist options
  • Save digitalronin/225970 to your computer and use it in GitHub Desktop.
Save digitalronin/225970 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Script to take a local git project and set up a remote project on our
# git server
# NB: This assumes your current working dir is the top-level of the project
# you want to send to the remote server, and that the local project is
# already a git repo.
GIT_SERVER=yourgitserver
GIT_HOME=/home/remoteuser/git
cwd=`pwd`
THIS_PROJECT=`basename $cwd`
# Create the remote repo
ssh $GIT_SERVER "mkdir ${GIT_HOME}/${THIS_PROJECT}.git && cd git/${THIS_PROJECT}.git && git init --bare"
# Add the remote repo to this project
git remote add origin ssh://${GIT_SERVER}${GIT_HOME}/${THIS_PROJECT}.git
# Send the latest version to the remote server
git push origin master
# Track the remote master branch
cat >> .git/config << MASTER
[branch "master"]
remote = origin
merge = refs/heads/master
MASTER
# Check we're up to date
git push
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment