Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Possible for git to commit automatically when file changes?

I'm experimenting with new ways of tracking changes to my Photoshop files when I design and I'd like to know; is it possible to create a script which automatically creates a commit when a change to a file is made (saved).

I use tools like Pixelapse however there are some drawbacks, and one of them is reverting back to previous versions can be a pain because you need to load the website.

Everytime I save my my changes in Photoshop, I'd like git to create a commit.

Having this happen automatically I'm sure will produce some undesirable effects like massive file sizes however I'm open to other suggestions.

Update: By the way I'm using Mac OS X if that helps.

like image 453
limitlessloop Avatar asked Jul 07 '26 18:07

limitlessloop


1 Answers

Maybe the inotify-tools is an option.

I don't know if they exist under MacOS X too. A Linux user would install it with yum install inotify-tools (RedHat) or aptitude install inotify-tools (Debian/Ubuntu).

You could then use inotifywait:

while [ true ]; do
  inotifywait -e modify test >/dev/null 2>&1
  echo "Do something"
done

To bring it into background, wrap it this way:

{ while [ true ]; do inotifywait -e modify test >/dev/null 2>&1 ; echo "Do something" ; done }& echo $! > ~/inotitfy.something.pid

It will endlessly loop and run inotifywait which will exit if the -e event occurs and then run echo in this example. After creating a background process through &. The backgrounded process ID will be piped into ~/inotitfy.something.pid.

Stop it by killing the process this way:

kill -15 `echo ~/inotitfy.something.pid`

You could also put the first variant into a screen.

Note that there might be a inotifyexec too (as on Debian Squeeze), but didn't worked for me all time and is not available on all distributions (so I always use my home-made approach).

like image 147
try-catch-finally Avatar answered Jul 10 '26 15:07

try-catch-finally



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!