简体   繁体   中英

In Git, how do I configure a hook to run a server-side commands after a commit is accepted?

I'm trying to figure out my way with the Django localistion stuff and from what i've understood, the makemessages command needs to be run every time you change some strings in code. I was thinking of simplifying this process by using a server-side Git hook.

I have no knowledge about Git hooks and couldn't find any resources on the web that did something like this. Is there a reason why one shouldn't have a Git hook to do something like this? If not, could you explain on how I could get the makemessages command to be run every time someone commits code to the repository?

Thanks

Sure thing!

Add a script called post-receive to the server side git repository in the .git/hooks/ directory.

Make sure that the file is executable.

Call makemessages from the script.

Done! (I think...)

You'll find some example scripts in the directory already, with most available hooks.

Have a look at the online Pro Git book if you need more information on Git hooks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM