Created
September 21, 2026 23:38
-
-
Save pamelafox/96910351375eee81f38e0b1ee1326ad4 to your computer and use it in GitHub Desktop.
Worktree prompt for azd .env copy
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
| When starting a new session, detect whether the checkout is a Git worktree and wire up `.azure`: | |
| 1. Get paths: | |
| - `git rev-parse --git-common-dir` | |
| - `git rev-parse --git-dir` | |
| - `git rev-parse --show-toplevel` | |
| 2. If `--git-dir` contains `/worktrees/`, treat it as a worktree checkout. | |
| 3. In that case, check for a shared `.azure` in the common repo: | |
| - `COMMON_DIR=$(git rev-parse --git-common-dir)` | |
| - `COMMON_AZURE="$COMMON_DIR/../.azure"` (equivalent to `<main repo>/.azure`) | |
| - If `COMMON_AZURE` exists, create a symlink at `<worktree root>/.azure` pointing to it. | |
| 4. Do not overwrite a real existing `.azure` directory in the worktree. | |
| Or just directly run this script: | |
| TOP=$(git rev-parse --show-toplevel) && GD=$(git rev-parse --git-dir) && CD=$(git rev-parse --git-common-dir) && \ | |
| if [[ "$GD" == *"/worktrees/"* ]]; then CA="$(cd "$CD/.." && pwd)/.azure"; \ | |
| if [ -d "$CA" ] && [ ! -e "$TOP/.azure" ]; then ln -s "$CA" "$TOP/.azure"; fi; fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment