Stanley H.I. Lio‎ > ‎

git


I'm working on a project where I have multiple single-board computers running the same set of scripts. I need a way to synchronize the source on them without having to manually SCP. I use git and github for this purpose. Some frequently used commands:

Setup a repository:
git init

Fetch a copy from a remote repo:
git clone https://github.com/stanleylio/fishy.git node

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 add <some file>
git commit -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