Unstage a file in git

Snippet

Add a file / directory to staging

git add filePath

Now, if you want to remove it from stage, but want to keep the changes you've made locally.

# unstage the file, remove it from the index, don't remove it from the working directory
# a commit will remove it from the repo
$ git rm --cached filePath
 
# unstage a file, keep the local changes
# YOU NORMALLY WANT THIS ONE
$ git reset filePath

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.