|9. .gitignore आणि Best Practices
Chapter 9Git & GitHub~1 min read

.gitignore आणि Best Practices

Professional Git वापरणे

.gitignore हा एक file आहे जो Git ला सांगतो — "या files/folders ला track करू नकोस." Passwords, API keys, node_modules, build folders — हे कधीही GitHub वर जाऊ नयेत.

.gitignore — common patterns

text
# Dependencies
node_modules/
vendor/

# Environment variables (NEVER commit these!)
.env
.env.local
.env.production

# Build output
dist/
build/
.next/

# OS files
.DS_Store
Thumbs.db

# IDE files
.vscode/
.idea/

# Logs
*.log
logs/

Commit Message Best Practices

Good vs Bad commit messages

text
# ❌ Bad — काय केलं ते सांगत नाही
git commit -m "fix"
git commit -m "update stuff"
git commit -m "asdfgh"

# ✅ Good — clear, imperative
git commit -m "Fix login button not working on mobile"
git commit -m "Add dark mode toggle to navbar"
git commit -m "Remove unused CSS from homepage"

# Multi-line commit (title + body)
git commit -m "Add user authentication

- Implement JWT tokens
- Add login/logout routes
- Store tokens in httpOnly cookies"

Git Aliases — Shortcuts

Useful git aliases

bash
git config --global alias.st status
git config --global alias.lg "log --oneline --graph --all"
git config --global alias.br branch
git config --global alias.co checkout

# आता वापरा
git st        # git status
git lg        # pretty log graph
git br        # git branch
💡

gitignore.io वेबसाइटवर जाऊन तुमच्या project type साठी ready-made .gitignore generate करता येतो.

Key Points — लक्षात ठेवा

  • .gitignore — files/folders track होऊ नयेत त्यासाठी
  • .env files NEVER commit करू नका
  • Commit messages: short, clear, imperative
  • node_modules नेहमी .gitignore मध्ये असावं
  • git alias — productivity shortcuts
0/10 chapters पूर्ण