git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: automatically removing missing files beneath a directory

From
Jeff King <peff@peff.net>
Date
May 8, 2008, 16:44 UTC
Message-ID
<20080508164456.GA29103@sigill.intra.peff.net>
In-Reply-To
<7f9d599f0805080939j3ef5e145w9bc2ac94f559b036@mail.gmail.com>
On Thu, May 08, 2008 at 09:39:22AM -0700, Geoffrey Irving wrote:
Show 7 quoted lines
> If I have a subdirectory in a git repository, and I remove some files
> without telling git, is there is a simple way to automatically run the
> equivalent of 'git rm' for all the missing files?  git commit -a would
> work, except that I only want to remove files beneath a particular
> subdirectory.  git add <directory> does the equivalent operation for
> adding files, but I don't see a way to automatically remove them
> without parsing the output of git status.

See "git add -u", which will update the status of all already-tracked files in paths you specify. Note that this will also stage changes in modified files. If you truly want to just mark all removed files, you can do something like:

  git ls-files --deleted -z | xargs -0 git rm
-Peff
Previous: Geoffrey IrvingNext: Geoffrey Irving
Message 2 of 5 in “automatically removing missing files beneath a directory”
  1. Geoffrey IrvingMay 8, 2008
  2. Jeff KingMay 8, 2008
  3. Geoffrey IrvingMay 8, 2008
  4. Jeff KingMay 8, 2008
  5. Geoffrey IrvingMay 8, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.