Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git still showing deleted files after a commit

Tags:

git

git-commit

How can I remove deleted files from my Git repo?

I've deleted a folder of a JavaScript library, which contained many files. I then went to commit the changes like so:

git add . git commit "message" git status 

But it shows all those files as "deleted ....".

How can I make them go away?

like image 301
Nik So Avatar asked Nov 29 '10 20:11

Nik So


People also ask

How do I remove a deleted file from my git repository?

Delete Files using git rm. The easiest way to delete a file in your Git repository is to execute the “git rm” command and to specify the file to be deleted. Note that by using the “git rm” command, the file will also be deleted from the filesystem.

Does git show deleted files?

Listing all the deleted files in all of git history can be done by combining git log with --diff-filter . The log gives you lots of options to show different bits of information about the commit that happened at that point.

Do I add deleted files to git commit?

To add a single file to the commit that you've deleted, you can do git add what/the/path/to/the/file/used/to/be . This is helpful when you have one or two deletions to add, but doesn't add a batch of deletions in one command.


2 Answers

This will add deletes as well.

git add -u . 

Check what's staged to be committed with:

git status 
like image 121
Jamund Ferguson Avatar answered Sep 21 '22 11:09

Jamund Ferguson


If it lists the files under the "to be committed" section, then just proceed with the commit; the files will remain deleted. (Git tracks deletions too, not just changes.)

If it lists the files under the "changed but not updated" section, then you have two options:

  1. Undelete them by restoring the version in the index: git checkout path/to/folder
  2. Mark them deleted in Git, then commit: git rm -r path/to/folder
like image 34
cdhowie Avatar answered Sep 23 '22 11:09

cdhowie