Skip to content

Instantly share code, notes, and snippets.

@shanesveller
Created November 21, 2008 19:36
Show Gist options
  • Save shanesveller/27584 to your computer and use it in GitHub Desktop.
Save shanesveller/27584 to your computer and use it in GitHub Desktop.
Sake task to remotely create a bare git repo
desc 'Create a new git repository at $GITUSER@$HOST:$REPO/'
task 'git:repo:new' do
user = (ENV["GITUSER"] or "git")
host = ENV["HOST"]
repo = ENV["REPO"]
system("ssh root@#{host} 'cd /home/git/ && mkdir -p #{repo} && cd #{repo} && git --bare init && chown -R git:git /home/git/#{repo}'")
end
# Must have root access, repo owner defaults to 'git'
# Using root user is to account for my preference to use git-shell as the shell on my 'git' user accounts
# Example usage:
# sake git:repo:new GITUSER=git HOST=git.mywebsite.com REPO=sakefiles
# Would create a new git repo available at [email protected]:sakefiles/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment