Skip to content

Instantly share code, notes, and snippets.

@Merovex Merovex/auto-commit.rb
Last active Apr 2, 2017

What would you like to do?
Auto Commit Git repo to GitHub
#!/bin/ruby"/PATH-TO/.auto-commit").split("\n").each do |dir|
next if `find . -newer .last-mod`.split("\n").empty? # No change to file system
puts "### #{"%Y-%m-%d %H:%M:%S")} (#{dir}) ###"
`git pull origin $(git symbolic-ref HEAD | cut -d'/' -f3)`
`git add . -A`
puts `git commit -am "Auto-commit: #{"%Y-%m-%d %H:%M:%S")}"`
puts `git push origin $(git symbolic-ref HEAD | cut -d'/' -f3)` if (ARGV[0] == 'push') ? true : false
`touch .last-mod`

This comment has been minimized.

Copy link
Owner Author

Merovex commented Apr 2, 2017

*/5 * * * * ~/bin/git-commit.rb >> ~/Writing-Projects/writing-data/auto-push.log 2>&1
0 * * * * ~/bin/git-commit.rb push >> ~/Writing-Projects/writing-data/auto-push.log 2>&1

I have it so that Root's .ssh config points to my GitHub credentials

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.