Last active
April 29, 2026 16:47
-
-
Save paulodiovani/90796246c8ce9f25da6d9a31e1dd4f9d to your computer and use it in GitHub Desktop.
Copy configs and run project setup steps when creating worktrees.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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