0

How to remove a file from the "git add " index if it has not yet been commited to the master branch.

I do not wish to actually delte the file itself ,just remove it from the index. TIA

CodeWizard
  • 128,036
  • 21
  • 144
  • 167
  • 3
    Possible duplicate of [How to undo 'git add' before commit?](http://stackoverflow.com/questions/348170/how-to-undo-git-add-before-commit) – Arkej Nov 12 '16 at 09:45

2 Answers2

6
git reset filepath

This will remove the file from add index and the changes will remain on your local system.

Niranjan Kumar
  • 1,438
  • 1
  • 12
  • 29
2

You simply have to delete it form the index using this simply rrm command:

git rm --cached <file name>

If you will use

git rm <file>

it will remove it from both your file directory and your index, using the --cache flag will only remove it from your index.

Once you have removed the file you have to commit the change so use the git commit --ammend to modify the last commit.
It will remove the file from the last commit along side with all other changes which you have made.

CodeWizard
  • 128,036
  • 21
  • 144
  • 167