Please see the most up-to-date version of this protocol on my blog at https://darencard.net/blog/.
- Make sure
inotify-tools
is installed (https://github.com/rvoicilas/inotify-tools) - Configure git as usual
- Clone the git repository of interest from github and, if necessary, add file you want to monitor
- Allow username/password to be cached so you aren't asked everytime
git config credential.helper store
- Open a terminal and navigate, as necessary; issue the following command
# <<branch>> = branch you are pushing to
# <<file>> = file you want to monitor
inotifywait -q -m -e CLOSE_WRITE --format="git commit -m 'auto commit' %w && git push origin <<branch>>" <<file>> | bash
- In a separate shell, do whatever you want and when monitored file is updated, it will automatically get committed and pushed (as long as the shell with the
inotifywait
command is still active)
- Make sure
fswatch
is installed (https://github.com/emcrisostomo/fswatch) - Configure git as usual
- Clone the git repository of interest from github and, if necessary, add file you want to monitor
- Allow username/password to be cached so you aren't asked everytime
git config credential.helper store
- Create a script that performs the commit and push (auto_commit_push.sh)
#!/bin/bash
# <<branch>> = branch you are pushing to
git commit -m "auto commit" $1
git push origin <<branch>>
- Open a terminal and navigate, as necessary; issue the following command
# <<file>> = file you want to monitor
# <<path/to/auto_commit_push.sh>> = path to the script created above
fswatch -0 <<file>> | xargs -0 -n 1 bash <<path/to/auto_commit_push.sh>>
- In a separate shell, do whatever you want and when monitored file is updated, it will automatically get committed and pushed (as long as the shell with the
fswatch
command is still active)
Would this work on a directory of files? I have an application running that changes different file at different time in a directory, so ideally would like to be able to check which files were changed weekly, and the commit and push those only