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 can I convert MP3 file to a Base64 encoded string? [closed]
- error: src refspec master does not match any
- How to cherry pick from 1 branch to another
- What is a sanity test/check
- How to Git stash pop specific stash in 1.8.3?
- What is an instance variable in Java?
- Discord music bot not working
- How to merge branch to master?
- Git: How do I force “git pull” to overwrite local files?
- What happens when I do git pull origin master in the develop branch?
- Difference between binary semaphore and mutex
- Hard reset of a single file
- How do I ignore an error on ‘git pull’ about my local changes would be overwritten by merge?
- Echo newline in Bash prints literal \n
- Raise to power in R
- How to change folder with git bash?
- Git:nothing added to commit but untracked files present
- Reason for the exception java.lang.VerifyError: Bad type on operand stack
- Does Git Add have a verbose switch
- pip connection failure: cannot fetch index base URL http://pypi.python.org/simple/
- pandoc document conversion failed with error 43 : pdflatex: The memory dump file could not be found
- ERROR: transport error 202: bind failed when starting Tomcat 7 in debug mode
- Git keeps prompting me for a password
- Arithmetic Overflow in mips
- How to change angular port from 4200 to any other
- Resolve Git merge conflicts in favor of their changes during a pull
- Git stash pop- needs merge, unable to refresh index
- Render HTML string as real HTML in a React component
- How to draw lines in Java
- Styling Select Drop down box
- How do I run git log to see changes only for a specific branch?
- What is “pass-by-name” and how does it work exactly?
- is it possible to get the MAC address for machine using nmap
- How to search in commit messages using command line?
- Ignore .pyc files in git repository
- Import error No module named skimage
- Git push hangs when pushing to Github?
- mport win32ui in python 3.6
- Getting Started with Subversion, Git, or similar Version Control System to keep a History of my Files? [closed]
- Call to undefined function `get_plugin_data()`
- Contact Form 7 – Execute code AFTER mail send [closed]
- When I try to install VersionPress, it tells me, “The package could not be installed. No valid plugins were found.”
- Rendering javascript in render_callback php Code
- Underscore Based Theme File Permissions in Git
- Manually updating plugins via FTP or SCM
- Any benefit or detriment from removing a pagefile on an 8 GB RAM machine?
- How do I view the details of a digital certificate .cer file?
- How do you validate fstab without rebooting?
- DNS – NSLOOKUP what is the meaning of the non-authoritative answer?
- Why can’t a CNAME record be used at the apex (aka root) of a domain?
- How can I upgrade to Java 1.8 on an Amazon Linux Server?
- What port should I open to allow remote desktop?