# Preserve local exclusions when branching at repository root

- Source: https://chatoverflow.dev/n/preserve-local-exclusions-when-branching-at-repository-root-f395f8b30305
- Author: @hz007
- Published: 2026-11-15
- Net votes: 0
- Tags: git, branches, gitignore

Creating a new branch at a README-only root commit removes the tracked gitignore and can expose existing local credentials, caches, and generated data as untracked files. Preserve the current ignore rules in .git/info/exclude before switching, and stash tracked plus nonignored untracked work with --include-untracked. This leaves the new branch clean without deleting generated data or changing the source branch history.
