{"thread":{"id":"13437","subject":"automatically removing missing files beneath a directory","startedAt":"2008-05-08T16:39:22Z","lastAt":"2008-05-08T17:19:46Z","messageCount":5,"participants":["Geoffrey Irving","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"76379","messageId":"7f9d599f0805080939j3ef5e145w9bc2ac94f559b036@mail.gmail.com","threadId":"13437","inReplyTo":null,"subject":"automatically removing missing files beneath a directory","fromName":"Geoffrey Irving","fromEmail":"irving@naml.us","sentAt":"2008-05-08T16:39:22Z","receivedAt":"2008-05-08T16:39:22Z","isPatch":false,"sender":{"key":"irving@naml.us","avatar":"https://gravatar.com/avatar/52d7452fcd134aac0fa12f57a3bb7ef5f3f7e73ca0ab36736d06c6a6132de718?d=mp&s=160"},"body":"If I have a subdirectory in a git repository, and I remove some files\nwithout telling git, is there is a simple way to automatically run the\nequivalent of 'git rm' for all the missing files?  git commit -a would\nwork, except that I only want to remove files beneath a particular\nsubdirectory.  git add <directory> does the equivalent operation for\nadding files, but I don't see a way to automatically remove them\nwithout parsing the output of git status.\n\nThanks,\nGeoffrey\n"},{"id":"76380","messageId":"20080508164456.GA29103@sigill.intra.peff.net","threadId":"13437","inReplyTo":"7f9d599f0805080939j3ef5e145w9bc2ac94f559b036@mail.gmail.com","subject":"Re: automatically removing missing files beneath a directory","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-05-08T16:44:56Z","receivedAt":"2008-05-08T16:44:56Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, May 08, 2008 at 09:39:22AM -0700, Geoffrey Irving wrote:\n\n> If I have a subdirectory in a git repository, and I remove some files\n> without telling git, is there is a simple way to automatically run the\n> equivalent of 'git rm' for all the missing files?  git commit -a would\n> work, except that I only want to remove files beneath a particular\n> subdirectory.  git add <directory> does the equivalent operation for\n> adding files, but I don't see a way to automatically remove them\n> without parsing the output of git status.\n\nSee \"git add -u\", which will update the status of all already-tracked\nfiles in paths you specify. Note that this will also stage changes in\nmodified files. If you truly want to just mark all removed files, you\ncan do something like:\n\n  git ls-files --deleted -z | xargs -0 git rm\n\n-Peff\n"},{"id":"76382","messageId":"7f9d599f0805081012ke0b342ct55a3aac1b37b158a@mail.gmail.com","threadId":"13437","inReplyTo":"20080508164456.GA29103@sigill.intra.peff.net","subject":"Re: automatically removing missing files beneath a directory","fromName":"Geoffrey Irving","fromEmail":"irving@naml.us","sentAt":"2008-05-08T17:12:56Z","receivedAt":"2008-05-08T17:12:56Z","isPatch":false,"sender":{"key":"irving@naml.us","avatar":"https://gravatar.com/avatar/52d7452fcd134aac0fa12f57a3bb7ef5f3f7e73ca0ab36736d06c6a6132de718?d=mp&s=160"},"body":"On Thu, May 8, 2008 at 9:44 AM, Jeff King <peff@peff.net> wrote:\n> On Thu, May 08, 2008 at 09:39:22AM -0700, Geoffrey Irving wrote:\n>\n>> If I have a subdirectory in a git repository, and I remove some files\n>> without telling git, is there is a simple way to automatically run the\n>> equivalent of 'git rm' for all the missing files?  git commit -a would\n>> work, except that I only want to remove files beneath a particular\n>> subdirectory.  git add <directory> does the equivalent operation for\n>> adding files, but I don't see a way to automatically remove them\n>> without parsing the output of git status.\n>\n> See \"git add -u\", which will update the status of all already-tracked\n> files in paths you specify. Note that this will also stage changes in\n> modified files. If you truly want to just mark all removed files, you\n> can do something like:\n>\n>  git ls-files --deleted -z | xargs -0 git rm\n>\n> -Peff\n\nCool.  \"git add -u && git add .\" does exactly what I want.\n\nThis is only indirectly mentioned in the documentation.  If you think\nit's reasonable to mention it more explicitly, I've attached a patch.\n\nThanks,\nGeoffrey\n\n\nFrom 698a0b7341647a0ce9e7abb36fe9357400e6bb59 Mon Sep 17 00:00:00 2001\nFrom: Geoffrey Irving <irving@naml.us>\nDate: Thu, 8 May 2008 10:00:04 -0700\nSubject: [PATCH] Explicitly note in documentation that git-add -u removes files.\n\n---\n Documentation/git-add.txt |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/git-add.txt b/Documentation/git-add.txt\nindex 35e67a0..f7a8b03 100644\n--- a/Documentation/git-add.txt\n+++ b/Documentation/git-add.txt\n@@ -74,7 +74,8 @@ OPTIONS\n \tUpdate only files that git already knows about. This is similar\n \tto what \"git commit -a\" does in preparation for making a commit,\n \texcept that the update is limited to paths specified on the\n-\tcommand line. If no paths are specified, all tracked files in the\n+\tcommand line. Files that are missing are removed (as if 'rm' had\n+\tbeen run). If no paths are specified, all tracked files in the\n \tcurrent directory and its subdirectories are updated.\n \n \\--refresh::\n-- \n1.5.4.5\n\n"},{"id":"76384","messageId":"20080508171843.GA29607@sigill.intra.peff.net","threadId":"13437","inReplyTo":"7f9d599f0805081012ke0b342ct55a3aac1b37b158a@mail.gmail.com","subject":"Re: automatically removing missing files beneath a directory","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-05-08T17:18:43Z","receivedAt":"2008-05-08T17:18:43Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, May 08, 2008 at 10:12:56AM -0700, Geoffrey Irving wrote:\n\n> Cool.  \"git add -u && git add .\" does exactly what I want.\n> \n> This is only indirectly mentioned in the documentation.  If you think\n> it's reasonable to mention it more explicitly, I've attached a patch.\n\nYeah, the term \"update\" is not really defined there. I actually prefer\nto mention it even earlier in the paragraph; does this make sense to\nyou?\n\ndiff --git a/Documentation/git-add.txt b/Documentation/git-add.txt\nindex 35e67a0..e2389e3 100644\n--- a/Documentation/git-add.txt\n+++ b/Documentation/git-add.txt\n@@ -71,7 +71,9 @@ OPTIONS\n \tthe specified filepatterns before exiting.\n \n -u::\n-\tUpdate only files that git already knows about. This is similar\n+\tUpdate only files that git already knows about, staging modified\n+\tcontent for commit and marking deleted files for removal. This\n+\tis similar\n \tto what \"git commit -a\" does in preparation for making a commit,\n \texcept that the update is limited to paths specified on the\n \tcommand line. If no paths are specified, all tracked files in the\n"},{"id":"76385","messageId":"7f9d599f0805081019r16e3b6ahd14d55b7d32c6231@mail.gmail.com","threadId":"13437","inReplyTo":"20080508171843.GA29607@sigill.intra.peff.net","subject":"Re: automatically removing missing files beneath a directory","fromName":"Geoffrey Irving","fromEmail":"irving@naml.us","sentAt":"2008-05-08T17:19:46Z","receivedAt":"2008-05-08T17:19:46Z","isPatch":false,"sender":{"key":"irving@naml.us","avatar":"https://gravatar.com/avatar/52d7452fcd134aac0fa12f57a3bb7ef5f3f7e73ca0ab36736d06c6a6132de718?d=mp&s=160"},"body":"On Thu, May 8, 2008 at 10:18 AM, Jeff King <peff@peff.net> wrote:\n> On Thu, May 08, 2008 at 10:12:56AM -0700, Geoffrey Irving wrote:\n>\n>> Cool.  \"git add -u && git add .\" does exactly what I want.\n>>\n>> This is only indirectly mentioned in the documentation.  If you think\n>> it's reasonable to mention it more explicitly, I've attached a patch.\n>\n> Yeah, the term \"update\" is not really defined there. I actually prefer\n> to mention it even earlier in the paragraph; does this make sense to\n> you?\n>\n> diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt\n> index 35e67a0..e2389e3 100644\n> --- a/Documentation/git-add.txt\n> +++ b/Documentation/git-add.txt\n> @@ -71,7 +71,9 @@ OPTIONS\n>        the specified filepatterns before exiting.\n>\n>  -u::\n> -       Update only files that git already knows about. This is similar\n> +       Update only files that git already knows about, staging modified\n> +       content for commit and marking deleted files for removal. This\n> +       is similar\n>        to what \"git commit -a\" does in preparation for making a commit,\n>        except that the update is limited to paths specified on the\n>        command line. If no paths are specified, all tracked files in the\n\nYep, that's better than mine.\n\nGeoffrey\n"}]}