What not to commit
Last updated:
Secrets
Section titled “Secrets”An API key or password ended up in a commit.
git rm --cached .envIf .env was already pushed, rotate the key first, then stop tracking the file. Rewriting history to remove it is optional and never enough on its own: every existing clone still has a copy.
.envgit add .gitignoregit commit -m "Stop tracking .env"Build output and dependencies
Section titled “Build output and dependencies”node_modules/dist/*.loggit add .gitignoregit commit -m "Ignore build output"Start from your framework’s .gitignore template and keep it short: only the paths your build produces.
Your editor’s files
Section titled “Your editor’s files”git config --global core.excludesFile ~/.gitignore_global.DS_StoreThumbs.db.idea/.vscode/This file lives outside the repository and applies to every repository on your machine, so it belongs to you, not to the project.
Large binaries
Section titled “Large binaries”A binary file that changes often, such as a design file or a video, bloats a repository fast because Git keeps every version. See Large files with Git LFS for how to track it instead.
Line endings
Section titled “Line endings”* text=autoA file committed with Windows line endings (CRLF) shows as fully changed to a teammate on macOS or Linux, and the other way around. .gitattributes tells Git to normalize line endings on checkout and commit.
git add --renormalize .git commit -m "Normalize line endings"What’s next
Section titled “What’s next”Git basics is licensed under CC BY 4.0: copy it, adapt it, keep the credit.

