18 January 2011

for future reference: a public git repository on nearlyfreespeech.net

Just in time for the new semester to start, I've learned something! I wanted to sync some files that I work on across a bunch of machines; git seemed like a reasonable choice (and unfortunately, Dropbox wasn't going to work).

Thus:

#First, create a bare repository on nearlyfreespeech.net
ssh user@ssh.phx.nearlyfreespeech.net
cd /home/public
mkdir -p git/dotfiles_repo.git
cd dotfiles_repo.git
git init --bare
git --bare update-server-info
mv hooks/post-update.sample hooks/post-update
exit

#Then, clone repo onto local machine
git clone http://mysubdomain.nfshost.com/git/dotfiles_repo.git .dotfiles
find . -maxdepth 1 -type f -name ".*" -exec cp {} .dotfiles/ \;
cd .dotfiles
git add *
git commit -m "initial add of files"
git push ssh://user@mysubdomain.nfshost.com/git/dotfiles_repo.git

# test out your commit
cd ~
rmdir .dotfiles
git clone http://mysubdomain.nfshost.com/git/dotfiles_repo.git .dotfiles

#update your local copy
git pull

# update the public repository copy
git push ssh://...

Note that placing your files in the 'public' directory makes them open to the world. If this isn't what you want, place your repository in /home/protected/ or somewhere else safe.

No comments:

Post a Comment