From 06ad304286e900a8de8745f658dd0200db9643bf Mon Sep 17 00:00:00 2001 From: Misbah Syed <35427888+misbahsy@users.noreply.github.com> Date: Tue, 29 Sep 2026 01:26:21 -0700 Subject: [PATCH] fix(quickstart): keep generated .env out of git in an existing repository folder When LITELLM_DIR is inside a git repository that does not ignore .env, add //.env to the clone's local exclude list (.git/info/exclude) instead of only warning. Tracked files, including .gitignore, are not touched --- scripts/quickstart.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/quickstart.sh b/scripts/quickstart.sh index b7829552515..3b2bef209f7 100755 --- a/scripts/quickstart.sh +++ b/scripts/quickstart.sh @@ -157,8 +157,14 @@ pick_folder() { printf '*\n' >.gitignore elif command -v git >/dev/null 2>&1 && git rev-parse --is-inside-work-tree >/dev/null 2>&1 && ! git check-ignore -q .env 2>/dev/null; then - # Never write ignore rules into a folder that already existed, such as a repository root. - echo "Note: $DIR/.env will hold your keys and is not ignored by git. Add .env to your .gitignore." + # In a folder that already existed, such as a repository root, leave the + # tracked .gitignore alone and add only .env to this clone's local exclude + # list, so the generated keys cannot be committed. + exclude="$(git rev-parse --git-path info/exclude)" + mkdir -p "$(dirname "$exclude")" + exclude="$(cd "$(dirname "$exclude")" && pwd)/exclude" + printf '/%s.env\n' "$(git rev-parse --show-prefix)" >>"$exclude" + echo "Added .env to this repository's local git exclude list ($exclude), so your keys stay out of commits." fi }