3 ms·
What's a (common) example use case for a post-checkout hook?
by jancsika 8y ago
What's a (common) example use case for a post-checkout hook?
- lainga 8y agoPulling a dependency project when a dependent project is checked out maybe
- ethomson 8y agoThat's a really interesting question. I tried to think about that when I was writing this blog post and couldn't really think about anything. Perhaps setting some permissions on a file or running `chattr` / `setfacl` is the best idea I had, but I omitted any suggestions because I've never actually used a post-checkout hook in anger.
- avar 8y agoThe post-checkout hook gets used for things like concatenating JS and CSS assets in a repository that's meant to house templates, i.e. a poor man's invocation of "make" whenever a user does a "git pull" without the user having to do anything extra. It can also be used for other cases where you'd like to amend what git does by default when updating the tree. See this recent thread[1] where some users want to have mtime behavior on files that's different from git's defaults, and one way to do that is via a post-checkout hook. 1. https://public-inbox.org/git/20180413170129.15310-1-mgorny@gentoo.org/ https://public-inbox.org/git/20180413170129.15310-1-mgorny@g...
- knodi123 8y agoI'm stretching here, but maybe compiling assets with webpack and then HUPing your web server? So when you switch between branches, your local server is always ready to serve up the version you've got on disk?
- berbec 8y agoI use a set of pre/post hooks to save uid & permission data for a repo that contains www & system data.
- nh2 8y agoChecking out submodules. Put git submodule sync && git submodule update --init --recursive into `.git/hooks/post-checkout` and never again wonder why your code doesn't work after switching branches (because you forgot to update submodules). Also put it into `post-rewrite` so that the same works for `git rebase`.
- lolc 8y agoIn one repo I use the post-checkout script is "npm install" so I always get the package versions for the branch I just checked out. One less thing to worry about.
- Piskvorrr 8y agoNotifications. Not for people, but for machines: "checkout is complete on X, and you're subscribed to this event, now do something based on that." If you publish on any event, it's the client's responsibility to choose which it wishes to subscribe to.