If you are using Git for your source code management, GitHub is an awesome tool. It especially shines for public projects where you freely allow others to fork your code and possibly pull patches back in.
Sometimes I'm just working on a project that I would prefer to keep in a private repository. GitHub provides paying accounts with such an option. However, I already have hosting accounts that are terribly underused. Here is a little script I use to create a remote git repository on one of my VPS accounts that I can then pull from and push to.
A hosting account which you can ssh / scp into.
$ vim new_repo
# You must adjust these variables for your specifc hosting account.
# Remote user you will connect as.
# The IP address you will SSH / SCP to.
# The remote path you wish to store your .git repositories in.
if [ -d $1 ]; then
echo "EXITING: Local directory '$1' already exists."
git add .
git commit -m "Initial Repository Creation"
git clone --bare $1/.git $1.git
echo "** Copying new repository $1.git to $REMOTE_HOST:$REMOTE_REPO_PATH"
scp -r $1.git $REMOTE_USER@$REMOTE_HOST:$REMOTE_REPO_PATH
rm -rf $1.git
rm -rf $1
echo "** Cloning locally at $PWD/$1"
git clone $REMOTE_USER@$REMOTE_HOST:$REMOTE_REPO_PATH$1.git
Or get it from GitHub
Once that is done, provide executable permissions.
$ chmod +x new_repo
That's it. Now if you execute:
$ ./new_repo testing
You will end up with /home/user/repos/testing.git on your remote host, and ./testing locally. From ./testing you can git push to send commits to the remote repository, and git pull to retrieve from the remote repository.
If you see room for improvement, I'm sure there is some, please leave a comment with your revision!