Git File Tracking and .gitignore
a. Tracking New, Modified, and Deleted Files
Git automatically tracks file changes, and you can monitor them using:
1. git status
Shows what files are:
• Untracked (new)
• Modified
• Deleted
Example Output:
Untracked files:
newfile.txt
Changes not staged for commit:
modified: app.js
deleted: oldfile.txt
2. git add file
Stages files (new or modified) to be committed.
3. git rm file
Tells Git to track file deletion.
________________________________________
b. Creating .gitignore File
.gitignore tells Git to ignore specific files/folders — they won't be staged or committed.
Common use cases:
• *.log – Log files
• node_modules/ – Dependency folders
• .env – Secrets/configs
Example .gitignore:
*.log
.env
__pycache__/
node_modules/
Create it manually:
touch .gitignore
Git will automatically skip these patterns when adding changes.
コメント