Yes you can tell Git to stop paying attention to your messy build folders and temporary trash. It will not hold a grudge but it will keep ignoring those files until you change your mind. This short guide shows how to create a .gitignore file for ignore folders and ignore directories and how to remove already tracked folders from the repository index with a few polite commands.
A .gitignore file lists patterns that tell Git to ignore matching files for future commits. If a file is already tracked then adding it to .gitignore will not magically untrack it. You will need to remove the file from the index first and then commit that change.
node_modules/
ignore a whole dependency treebuild/
or dist/
ignore compiled output*.log
ignore log files that always blame you!.gitkeep
or !docs/keep.md
unignore a needed file inside an ignored folderFollow these steps to add ignore rules and stop Git from tracking specific directories. It is quick and mildly satisfying.
.gitignore
at the repository root if you do not already have onenode_modules/
or build/
*.log
or dist/
!docs/keep.md
If a folder was committed before the .gitignore rule was added you must remove the tracked copy from the index. These commands remove tracking without deleting the files from your working directory.
git rm -r --cached foldername
# or remove multiple at once
git rm -r --cached .
After running the removal add the changes and commit them so the remote repo stops tracking new files that match your ignore rules.
git add .
git commit -m "Update .gitignore and untrack folders"
git push
git ls-files -i --exclude-standard
git check-ignore -v path/to/file
git status
before you push anything dramaticIf you are tired of adding the same OS or editor junk to every repo set a global ignore file and forget about the problem forever.
git config --global core.excludesfile ~/.gitignore_global
# then edit ~/.gitignore_global and add patterns like
# Thumbs.db
# .DS_Store
# *.swp
There you go. Your repo will now behave better and your commits will stop including temporary garbage. You can get back to whatever heroic bug fixing you were doing before Git became the trash collector.
I know how you can get Azure Certified, Google Cloud Certified and AWS Certified. It's a cool certification exam simulator site called certificationexams.pro. Check it out, and tell them Cameron sent ya!
This is a dedicated watch page for a single video.