Workflows

GIT is very powerful and complex version control system, allowing to implement different workflows for various purposes.

Backup

Some time ago GitHub announced generous offer, unlimited amount of private repositories. That means you can use it as backup of your configurations.

So you get for free except of backup:

  • versioning;

  • Web interface for viewing and editing;

  • audit of made changes.

Think about confidential data in configurations.

Example of backup for /etc/nginx of pzdc.de

Create new repo: https://github.com/new with name pzdc.de-etc-nginx

Copy SSH URL, e.g: git@github.com:Pingvin235/pzdc.de-etc-nginx.git

Take public SSH key and add it to link:https://github.com/settings/keys

Create local GIT repo:

cd /etc/nginx
git init && git add . && git commit -m "Init"
git remote add origin git@github.com:Pingvin235/pzdc.de-etc-nginx.git
git push -u origin master

Do after any change:

git add . && git push origin master

One direction

The workflow may be useful for remote update of static Web sites content or configurations.

When selecting the workflow, you must not do changes directly in your remote directory. Otherwise their will be lost.

Assuming you have remote Web server bgerp.org with static content placed in www.bgerp.org directory. And there is a www user, allowed to reach the directory.

The directory has to be configured with a GIT repository you using, e.g:

git remote add origin  git@github.com:Pingvin235/bgerp-website-org.git

All the changes are performed in local GIT repository branch based. So you have to create a branch first:

git checkout -B my-change-branch

After do all wanted changes, commit and push them:

git add . && git commit -m "Comment" && git push
On first branch push you will be asked about connecting a local branch with remote one.

And now you can make remote SSH call for fetching the changes:

ssh www@bgerp.org "cd www.bgerp.org && git fetch && git checkout origin/my-change-branch"

Of course you can join push and remote fetch command lines together.