Joyent

Translations of this page:

Git on Shared Accelerators

This page is a guide to using the Git version control system on Shared Accelerators.

Git Overview

If you're new to Git, or want a general introduction to using Git for version control, start off by reading the Git Overview in the All Accelerators Knowledge Base.

Create a Git Repository

git should be installed and ready to use on Shared Accelerators. These instructions make the assumption that you would like to keep your Git repositories in the /users/home/username/git/ directory.

Create a git directory in your home directory, if it does not already exist:

  mkdir -p ~/git

To create a new, empty Git repository on your Shared Accelerator:

  mkdir git/appname.git
  cd git/appname.git
  git --bare init

Then, to push an (existing) app from your local machine up to your newly-created remote repository.

  cd appname
  git add .
  git commit -m "initial import"
  git remote add origin ssh://username@servername.joyent.us/users/home/username/git/appname.git
  git push origin master

Create a shared Git Repository

A shared git repository will give commit access to any user that has git-shell access to your account. This is enabled in Virtualmin, in the Edit Mail and FTP Users section, by setting Login Permissions to Email and GIT.

Follow the instructions given above for creating a git repository.

Warning: Any users that you grant git access to will be able to commit to all shared repositories.

  chmod -R g+w myapp.git

Script to make setting up Git Repositories easier

I created this script to make the setup of git repositories much less time consuming. I store my git repositories in ~/git, then symlink the ones I want shared anonymously over http into ~/web/public/git/. I have this script at ~/git/new-project.sh

Note 1: This sets up shared repositories by default. You can comment out the chown if you don't want this behavior.
Note 2: Replace mydomain and mydomain.com with your domain name to get reasonable output.
Note 3: Replace username with your primary username.

#!/usr/local/bin/bash

if [[ "$#" -ne "1" ]]; then
	echo "You need to provide a project directory, eg: new-project.git"
	exit 1
fi

if [[ -d "$1" ]]; then
	echo "This project already exists. Exiting"
	exit 2
fi

# Create the directory to hold the project
mkdir "$1"
cd "$1"

# Create a new repository
git --bare init
cd ..

# Make the repository shared
chmod -R g+w "$1"

# Make the repository accessible over http
chmod +x "$1/hooks/post-update"

echo "All done"
echo
echo "To push some code, run:"
echo "git remote add mydomain ssh://mydomain.com/users/home/username/git/$1"
echo "git push --tags mydomain master"
echo
echo "If you want to share this over gitweb, don't forget to symlink it"
echo "If you want to share this over http, don't forget to symlink it"
echo "Symlinks should be created in web/public/git"
echo "ln -s \"`pwd`/$1\" ~/web/public/git/"
echo
echo "Have a nice day!"
 
shared/kb/git.txt · Last modified: 2008/04/18 03:11 by whatcould
 
Recent changes RSS feed Creative Commons License Driven by DokuWiki