Serverless git file sync

Git has powerful merge functionality, and can be used to help keep folders in sync between two systems. The largest hurdle is usually getting your “git remote” set up.

  1. cd into the directory you’d like to sync
  2. Type “git init” on your first server to initialize the repo.
  3. On your second server, type “git clone ssh://user@1.2.3.4/home/user/Folder/”

That should clone your files to the second server. The second server will run the “git-receive-pack” command to communicate with the first system. If you get the error “fatal: protocol error: bad line length character:”, check that the server isn’t breaking the sync with a welcome message. Manually run “ssh user@1.2.3.4 git-receive-pack /home/user/Folder/” to make sure there is no welcome message. If there is, you can modify your bashrc on server 1 to remove any welcome messages.
Or, if you want to keep your welcome message locally, but omit it with ssh:
if [[ -z $SSH_CONNECTION ]]; then
fortune
fi

To sync from server 1 to server 2, add it as a remote
git add remote server2 ssh://user@2.3.4.5/home/user/Folder/”

Share and Enjoy:
  • Print
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Yahoo! Buzz
  • Twitter
  • Google Bookmarks
No Comments Posted in Uncategorized

Leave a Reply

*

Using Gravatars in the comments - get your own and be recognized!

XHTML: These are some of the tags you can use: <a href=""> <b> <blockquote> <code> <em> <i> <strike> <strong>