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

1

2 Answers 2

6
git reset filepath

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

Sign up to request clarification or add additional context in comments.

Comments

3

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.