Skip to content

Instantly share code, notes, and snippets.

@paulodiovani
Last active April 29, 2026 16:47
Show Gist options
  • Select an option

  • Save paulodiovani/90796246c8ce9f25da6d9a31e1dd4f9d to your computer and use it in GitHub Desktop.

Select an option

Save paulodiovani/90796246c8ce9f25da6d9a31e1dd4f9d to your computer and use it in GitHub Desktop.
Copy configs and run project setup steps when creating worktrees.
#!/bin/sh
## .git/hooks/post-checkout
## only runs when creating new worktrees
if [ "$1" -eq "0000000000000000000000000000000000000000" ]; then
## Files to copy
files=(.env)
## Get the main worktree path
basePath="$(dirname "$(git rev-parse --path-format=absolute --git-common-dir)")"
## copy config files
for file in "${files[@]}"; do
cp "$basePath/$file" "$(pwd)/$file"
done
## run setup commands
# git submodule update
# bundle install
# ...
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment