Git on Shared Accelerators
This page is a guide to using the Git version control system on Shared Accelerators.
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
You may want to set the hook scripts to NOT be executable, as some of them give syntax errors when run (not sure how to reconcile this with the script below which sets them to be executable: +x, but this is what worked for me, albeit without hook functionality.):
chmod -x ~/git/*/hooks/*
Then, to push an (existing) app from your local machine up to your newly-created remote repository.
cd appname git init 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.
Note 4 (Warning): This script does not seem to work everywhere. If, when pushing a local git repository up you have problems such as http://discuss.joyent.com/viewtopic.php?id=23151, just set up the repository by hand.
#!/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!"
