Cron job checking for changes in Git repository
Posted
by
HNygard
on Server Fault
See other posts from Server Fault
or by HNygard
Published on 2012-06-19T20:28:38Z
Indexed on
2012/06/19
21:18 UTC
Read the original article
Hit count: 197
We have just moved our server configs to a Git repository. Therefore there should not be any changes in any of the repository folders. I was thinking about how I could set up a cron job to check for any uncommited changes.
How could a cron job be set up to check for changes in a Git repository?
Greping the output of the git status
command might just do it. Grep and cron jobs are not my strong side. Here are some sample outputs from git status
:
Standing the folder containing the git repository (e.g. /path/gitrepo/
) with changed files:
$ git status
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: apache2/sites-enabled/000-default
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# apache2/conf.d/test
no changes added to commit (use "git add" and/or "git commit -a")
Standing in the folder when there is no changes:
$ git status
# On branch master
nothing to commit (working directory clean)
Update:
Synced up with origin is not important. There should be no local changes. Local files that must be in place go into the .gitignore file. In addition to the server configs there are also git repos for content (static web sites, web apps, wordpress, etc). None of the repositories should have local changes.
We might use Puppet in the long run since its being used for development of one of the web apps.
© Server Fault or respective owner