- 01Getting Started
- 02What Is Git? Understanding Version Control
- 03Checking the Current State with git status
- 04Understanding the "Staging Area"
- 05Recording Changes with git commit
- 06Viewing History with git log
- 07Viewing Changes with git diff
- 08What Is a Branch?
- 09Switching Branches with git checkout
- 10Merging Branches with git merge
- 11Remote Repositories and git remote
- 12Sending Changes with git push
- 13Getting Code with git pull and git clone
- 14Shelving Work Temporarily with git stash
- 15Marking Releases with git tag
- 16Unstaging with git reset
- 17Untracking a File with git rm
- 18Ignoring Files with .gitignore
- 19Deleting a Branch with git branch -d
- 20Setting Your Name with git config
- 21Viewing the Latest Commit with git show
- 22Fetching Remote Info Only with git fetch
- 23Viewing History Compactly with git log --oneline
- 24Finding Who Changed a File with git blame
- 25Undoing a Commit with git revert
- 26Fixing the Last Commit with git commit --amend
- 27Viewing the Staged Diff with git diff --staged
- 28Visualizing History with git log --graph
- 29Switching Branches with git switch (the Newer Syntax)
- 30Renaming a Branch with git branch -m
- 31Filtering History by Author with git log --author
- 32Deleting a Stash with git stash drop
- 33Deleting a Tag with git tag -d
- 34Listing Remotes with git remote -v
- 35Replaying Your Branch with git rebase
- 36Viewing Changed Files Alongside History with git log --stat
- 37Staging and Committing Together with git commit -a
- 38Discarding File Changes with git checkout --
- 39Picking Just One Commit with git cherry-pick
- 40Recording a Rename with git mv
- 41Checking HEAD's Movement History with git reflog
- 42Applying a Stash Without Removing It with git stash apply
- 43Creating an Annotated Tag with git tag -a
- 44Filtering History by Date with git log --since
- 45Viewing the Actual Changes with git log -p
- 46Getting Just the Current Branch Name with git branch --show-current
- 47Creating an Empty Commit with git commit --allow-empty
- 48Searching Commit Messages with git log --grep
- 49Removing a Remote with git remote remove
- 50Understanding the Danger of git push --force
- 51Counting Commits per Author with git shortlog
- 52Returning to Your Previous Branch with git switch -
- 53Viewing One File's Diff with git diff <file>
- 54Listing Your Settings with git config --list
- 55Checking Status Compactly with git status -s
- 56Adding Only Changes with git commit --amend --no-edit
- 57Mastering the git commit -am Shorthand
- 58Adding a Message to a Stash with git stash push -m
- 59Searching Tags by Pattern with git tag -l
Untracking a File with git rm
This lesson covers removing a file from Git's tracking with git rm. It's for anyone searching "git rm --cached usage."
git rm removes a file from Git's management. Add the --cached flag and only Git's tracking is dropped, while the actual file stays right where it is.
In Try It, run git rm --cached app.js. The actual file app.js stays on your computer untouched, while it's removed from Git's history tracking.
A common early mistake is forgetting the --cached flag — without it, the actual file gets deleted too, so pay attention to make sure the outcome matches what you actually intended. In real teams, this command comes up for something like accidentally committing a secret file before setting up .gitignore, and needing to remove it from tracking.
🧑💻 You can type this command into the Git pseudo terminal to try it yourself (this page itself has no interactive terminal).
