How to delete files deleted from .git?

When I delete a file (or rename it) using mv, rmor some other object, the file is displayed as deleted when I do git status:

# Changes not staged for commit:
#   (use "git add/rm <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   deleted:    ../src/main/..../myFile.java

Before creating a commit, it is cumbersome to perform git rm <file>for each file, in particular, since the terminal does not have autocomplete for a file that does not exist.

Is there a shorter way to remove deleted files from a set of files tracked by git?

thank

+5
source share
5 answers

I believe that I git add -uwill do whatever I want from the documentation:

-u
--update
  Only match <filepattern> against already tracked files in the index 
  rather than the working tree. That means that it will never stage new
  files, but that it will stage modified new contents of tracked files
  and that it will remove files from the index if the corresponding file
  in the working tree have been removed.

Link: http://git-scm.com/docs/git-add

+4
source

, "a" commit:

$ git commit -am 'Message'

"a"

+3

, git add -u ( /). , git status.

+2

, , git commit -a. :

Tell the command to automatically stage files that have been modified
and deleted, but new files you have not told git about are not affected.
+1

, ...

Please note that unlike some other VCS, in Git, the command git rmdeletes the file from both the index and the work tree, unless otherwise specified (using the command line option --cached). Therefore, it is recommended that you delete your monitored files using git rm, first of all: you will get a full file name and do not need to mess with synchronizing the index state with the work tree.

+1
source

All Articles