Stanley Lio‎ > ‎

Git


I'm working on a project where I have multiple single-board computers running some scripts. I need a way to synchronize the source code on the computers without having to manually FTP and sync.

Git is all the rage now. To use it as a simple sync tool, here's the key commands:

Setup a repository:
git init

Fetch a copy from a remote repo, assuming no local repo exists:
git clone https://github.com/stanleylio/fishy.git

After the local repo is up and you've made some updates to the local files, to send the local changes to the remote repo:
git commit -a -m "message"
git push origin master

To update the local copies with those on the remote repo:
git pull origin master

If, however, the local machine already has some of the source files and you want to setup the repo there,
git remote add origin https://github.com/stanleylio/fishy.git

To discard the local versions (assuming they are not as fresh as the remote ones):
git fetch --all
git reset --hard origin/master