git rm --cached <filePath>
does not unstage a file, it actually stages the removal of the file(s) from the repo (assuming it was already committed before) but leaves the file in your working tree (leaving you with an untracked file).
git reset -- <filePath>
will unstage any staged changes for the given file(s).
That said, if you used git rm --cached
on a new file that is staged, it would basically look like you had just unstaged it since it had never been committed before.
Update git 2.24
In this newer version of git you can use git restore --staged
instead of git reset
. See git docs.
Related Posts:
- How do I use ‘git reset –hard HEAD’ to revert to a previous commit? [duplicate]
- How do I revert a Git repository to a previous commit?
- What is the `git restore` command and what is the difference between `git restore` and `git reset`?
- How to uncommit my last commit in Git [duplicate]
- Handling file renames in Git
- Delete commits from a branch in Git
- How to uncommit my last commit in Git [duplicate]
- ‘git’ is not recognized as an internal or external command
- ‘git’ is not recognized as an internal or external command
- How do I revert a Git repository to a previous commit?
- How to remove origin from git repository
- What’s the purpose of git-mv?
- git : Pull is not possible because you have unmerged files
- Why git asks to enter a commit message to explain why this merge is necessary
- How do I remove version tracking from a project cloned from git?
- How can I delete a file from a Git repository?
- How do I remove version tracking from a project cloned from git?
- git pull on a different branch
- How can I make Git “forget” about a file that was tracked, but is now in .gitignore?
- What is the meaning of git reset –hard origin/master?
- What is difference between ‘git reset –hard HEAD~1’ and ‘git reset –soft HEAD~1’?
- Download a specific tag with Git
- How to undo git reset –soft to get my changes back?
- Git push won’t do anything (everything up-to-date)
- git add . -> still “nothing to commit” with new files
- git submodule add error: does not have a commit checked out
- Can I delete a git commit but keep the changes?
- Git error on git pull (unable to update local ref)
- git status shows modifications, git checkout —
doesn’t remove them - How to resolve git’s “not something we can merge” error
- How can I undo git reset –hard HEAD~1?
- How to clone all remote branches in Git
- Update Git branches from master
- How to squash all git commits into one?
- How to interactively (visually) resolve conflicts in SourceTree / git
- How to revert a “git rm -r .”?
- Move existing, uncommitted work to a new branch in Git
- How can I delete all of my Git stashes at once?
- Git add all files modified, deleted, and untracked?
- git add only modified changes and ignore untracked files
- Remove node_modules from git in vscode
- What’s the use of the staging area in Git?
- git undo all uncommitted or unsaved changes
- git push –force-with-lease vs. –force
- How can I move a tag on a git branch to a different commit?
- Staging Deleted files
- What firewall ports need to be open to allow access to external git repositories?
- How do I prevent apache from serving the .git directory?
- How do I check out a remote Git branch?
- How do I delete a Git branch locally and remotely?
- What is git tag, How to create tags & How to checkout git remote tag(s)
- Using prevNext Modx Addon
- :wq! command in vim
- How do I delete a Git branch locally and remotely?
- how to set the background color of the status bar during the launching phase [duplicate]
- api-ms-win-crt-runtime-l1-1-0.dll is missing when opening Microsoft Office file [closed]
- How do I rename a local Git branch?
- When is K 1024 and when is it 1000?
- What is a MIME type?
- Logitech/LGHUB Lua – Loop with break
- What does ‘–set-upstream’ do?
- are there dictionaries in javascript like python?
- What does ‘–set-upstream’ do?
- How can I convert MP3 file to a Base64 encoded string? [closed]
- Understanding The Modulus Operator %
- Difference between “git add -A” and “git add .”
- Understanding the main method of python [duplicate]
- Dial pad to get phone number (with Android button images)
- TypeError: only integer scalar arrays can be converted to a scalar index with 1D numpy indices array
- Git: Message ‘src refspec master does not match any’ when pushing commits in Git
- How is the AND/OR operator represented as in Regular Expressions?
- TypeError: only integer scalar arrays can be converted to a scalar index with 1D numpy indices array
- Git: Message ‘src refspec master does not match any’ when pushing commits in Git
- error: src refspec master does not match any
- Istio Ingress resulting in “no healthy upstream”
- Why is it not possible to fake an IP address?
- How to open a “-” dashed filename using terminal?
- What does cherry-picking a commit with Git mean?
- Substring in excel
- How to cherry pick from 1 branch to another
- What is a LAMP stack?
- What is a sanity test/check
- What is the difference between POST and PUT in HTTP?
- How to Git stash pop specific stash in 1.8.3?
- What is the difference between POST and PUT in HTTP?
- How to use Git Revert
- How to find Google’s IP address?
- What exactly is a VBO in OpenGL?
- What and where are the stack and heap?
- ping response “Request timed out.” vs “Destination Host unreachable”
- Authentication versus Authorization
- How do I undo the most recent local commits in Git?
- What is a reverse shell?
- How does npm start work? What all processes are happening in the background?
- What is an instance variable in Java?
- What is the := operator?
- What is tail recursion?
- Discord music bot not working
- What does “:=” mean in Pseudocode? [closed]
- Why am I getting error for apple-touch-icon-precomposed.png