0

While git add -u stage all modified tracked files, it doens't remove deleted files.

I tried "git rm -u" but it didn't work. What is the git command for removing deleted tracked files ?

EDIT: with git status I see the deleted files under "Changes not staged for commit:"

I could checkout them and do a git rm on each... but there may be a better solution.

B2F
  • 255
  • 2
  • 10

2 Answers2

0

You should always delete tracked files using git rm - this will automatically stage the deletion, so that it's included in the next commit.

git add -A will stage absolutely everything that is not ignored - including deleted files, new files, and modified files.

Edit: as it turned out, the problem was that you were inside a subdirectry in your repo, and the method in this answer worked.

Community
  • 1
  • 1
1615903
  • 32,635
  • 12
  • 70
  • 99
  • I agree that using "git rm" would be the easy way, but this time I forgot and deleted these files with rm. – B2F May 24 '13 at 08:18
0

What version of git do you use ? I use version 1.7.9.5 and when I run git add -u, tracked files removed from the disk are staged for deletion.

Extra note : you don't need to run git checkout <file> before git rm <file>. You may need to use the -- command line separator to clearly indicate that you meant a file name, and not a branch name :

git rm -- <file>
LeGEC
  • 46,477
  • 5
  • 57
  • 104
  • I too use git 1.7.9.5, you are right it should work with "git add -u" but maybe it didn't because I actually moved the files. – B2F May 24 '13 at 09:22