Reputation: 2443
##!/bin/bash
## post-chekcout script
find . -type f -print0 | xargs -0 chmod 666
find . -type d -print0 | xargs -0 chmod 777
Above is my post-chekcout
hook, I want to :
After git checkout
,change all files in my working directory to mod 666
and change all folders to 777
.
But in this post,
This hook cannot affect the outcome of git checkout
How can I write post-checkout hook to chmod 666
to all files?
Upvotes: 2
Views: 259
Reputation: 94397
The sentence
This hook cannot affect the outcome of git checkout
means that exit code of the hook cannot prevent checkout being performed. The hook is ran after checkout and you can do anything in the worktree. For example:
#!/bin/sh
# post-checkout hook:
# chmod directories and executable files 0777,
# chmod other files 0666. Exclude .git.
find . \( -name .git -type d -prune \) -o -exec chmod a+rwX '{}' \+
Upvotes: 2