How to remove deleted files from showing up in my local git status?

uwe picture uwe · Nov 10, 2011 · Viewed 40.5k times · Source

A developer added an image directory on the server without adding that folder to the .gitignore file. When I did a git pull it pulled those files (hundreds of files). I added the folder to the .gitignore on the server but not my local system. I then deleted the files locally (permanently). When I do a git status all those deleted files still show up. How can I suppress them from showing up?

Update: thanks for all the great help. To make sure there is no misunderstanding: I do want to keep the files on the server; I just want to remove them from git.

Answer

NightFury13 picture NightFury13 · Apr 1, 2016

I find this to be the easiest way of doing the task.

$> git add -u <directory-path>   (or you may use --update)

Original State :

$> git status .

On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)
deleted:    .ipynb_checkpoints/Untitled-checkpoint.ipynb
deleted:    CVPR 1 hr tute-Backup.ipynb
deleted:    cifar10-test.t7
deleted:    cifar10-train.t7
deleted:    cifar10torchsmall.zip
deleted:    create_advr.lua
deleted:    criterion_cifar10_lr_0.001_epoch_13.t7
deleted:    train_cifar10.lua
deleted:    trained_net_cifar10_lr_0.001_epoch_13.t7

So, to remove all deleted files from my current directory, I use.

$> git add -u .
$> git commit -m "removing deleted files from tracking"
$> git push origin master

Final State :

$> git status .

On branch master
nothing to commit, working directory clean

Hope this helps :)