Code Snippets library
Code snippets library is a collection of short, ready-to-use code snippets with practical examples that you can quickly copy and use in your projects. It helps save time and solve common problems without digging through documentation.
Ways to Ignore Files in Git
#1. .gitignore
// Global ignore for all users (committed to repo)
// Files listed here are never tracked or added
# Example:
node_modules/
.env
.DS_Store
#2. .git/info/exclude
// Local ignore (applies only to your local repo)
// Works like .gitignore but is not shared
# Example:
vendor/swiper/
*.local.php
#3. --assume-unchanged
// Git stops checking for local changes
// File may still be overwritten by pull/merge
git update-index --assume-unchanged phpcs.xml.dist
git update-index --no-assume-unchanged phpcs.xml.dist
#4. --skip-worktree
// Ignore local changes to a tracked file
// Git won’t show or overwrite your local edits
// Ideal for environment configs
git update-index --skip-worktree .env
git update-index --no-skip-worktree .env
5 Useful git grep Commands
#1: Search your code instantly
git grep "function"
# Finds all lines containing "function" in tracked files
#2: Search within a specific branch
git grep "API_KEY" main
# Looks for "API_KEY" only in the 'main' branch
#3: Filter by file type
git grep "useEffect" -- '*.js'
# Searches only inside JavaScript files
#4: Count occurrences
git grep -c "console.log"
# Counts how many times "console.log" appears per file
#5: Search older commits
git grep "TODO" HEAD~10
# Searches for "TODO" in the code as it existed 10 commits ago