Ignore untracked generated files
#.gitignore affects intentionally untracked files. It does not untrack a file already in the index.
Fragment
--cached removes the index entry and keeps the working file. Commit the policy change deliberately.
Reference
Inspect, save, combine and recover work with clear command effects.
Modern Git CLI, including switch and restore (Git 2.23+). Independent examples use illustrative paths and branch names. Inspect status and diffs before changing files or history. Commands below are reference material, not executed by this guide.
.gitignore affects intentionally untracked files. It does not untrack a file already in the index.
Fragment
--cached removes the index entry and keeps the working file. Commit the policy change deliberately.
stash push stores tracked staged/unstaged changes; -u also includes untracked files. apply retains the stash; pop drops it only after a successful application.
Fragment
Ignored files need -a, which can capture large generated content. Applying may conflict; --index attempts to restore staging too.
A worktree has its own checked-out files and index while sharing repository objects and most refs. Normally the same branch cannot be checked out in two worktrees.
Fragment
A worktree lets another task stay separate without stashing the first task.
clean -n previews removal. -d includes untracked directories; -x includes ignored files. Preview scope before considering a real deletion.
Fragment
These examples only preview. A later -f deletion is not preserved in commit history.
--show-origin identifies which configuration file supplied each setting. --local scopes identity to the current repository.
Fragment
Names and email identify commits; they do not establish authentication or authorization.
clone creates a local repository from an existing one, normally configures origin and checks out its initial branch. init creates repository metadata in a new or existing directory; it does not upload files.
Fragment
The clone URL is illustrative. init -b requires Git 2.28+. These are alternative starting points.
A trailing / targets directories. A slash at the start or in the middle anchors a pattern to its ignore file’s directory; a pattern with no other slash matches at any depth. ! negates a rule; an excluded parent directory prevents Git from discovering a re-included child.
Fragment
Ignore files are not a secret-protection mechanism and do not stop tracking existing index entries.