I just wanted to get this written down somewhere before I forget how I did it or forget how to use it.
I installed git on my server. I added my ssh key to the server:
scp ~/.ssh/id_rsa.pub [username]@[server]:.ssh/authorized_keys
I then wrote the following script (I actually stole most of it but that’s moot. Credit goes to Johan Harjono)
#!/bin/sh ##################################### # Stephen Cott # 10 DEC 2011 # # createGitRepo.sh # Script to create a local git # repository and configure it on a # remote server ##################################### repo_name=$1 language=$2 remote_user=xxxx remote_server=xxxx mkdir $repo_name cd $repo_name git init touch README git add README git commit -m "Initial Commit" cd .. git clone --bare $repo_name ${repo_name}.git scp -r ${repo_name}.git ${remote_user}@${remote_server}:~/code/${language}/ rm -Rf ${repo_name}.git cd $repo_name git remote add $repo_name ssh://${remote_user}@${remote_server}/home/[username]/code/${language}/${repo_name}.git
That script creates a new directory in the current directory using the first argument, the it initializes the directory for git. After that it clones the git repository to same name .git and initialzes a bare git structure. Then it scp’s that git repository up to my server into a subdirectory of code dependent on the second argument which is the language type and deletes the local *.git copy. Finally it moves back into the newly created project folder and sets up a git remote.
It’s pretty simple to use after that. If I am working on another system and want to pull a project I would use:
git clone ssh://[username]@[server]:/home/[username]/code/[language]/[reponame].git [localreponame]
Do whatever work I need to do on the project and then:
git pushWhen I’m back at my main workstation I just need to do:
cd [localreponame] git pull
And then my main workstation is up to date.