git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* automatically removing missing files beneath a directory
@ 2008-05-08 16:39 Geoffrey Irving
  2008-05-08 16:44 ` Jeff King
  0 siblings, 1 reply; 5+ messages in thread
From: Geoffrey Irving @ 2008-05-08 16:39 UTC (permalink / raw)
  To: git

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.

Thanks,
Geoffrey

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: automatically removing missing files beneath a directory
  2008-05-08 16:39 automatically removing missing files beneath a directory Geoffrey Irving
@ 2008-05-08 16:44 ` Jeff King
  2008-05-08 17:12   ` Geoffrey Irving
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff King @ 2008-05-08 16:44 UTC (permalink / raw)
  To: Geoffrey Irving; +Cc: git

On Thu, May 08, 2008 at 09:39:22AM -0700, Geoffrey Irving wrote:

> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: automatically removing missing files beneath a directory
  2008-05-08 16:44 ` Jeff King
@ 2008-05-08 17:12   ` Geoffrey Irving
  2008-05-08 17:18     ` Jeff King
  0 siblings, 1 reply; 5+ messages in thread
From: Geoffrey Irving @ 2008-05-08 17:12 UTC (permalink / raw)
  To: Jeff King; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 1131 bytes --]

On Thu, May 8, 2008 at 9:44 AM, Jeff King <peff@peff.net> wrote:
> On Thu, May 08, 2008 at 09:39:22AM -0700, Geoffrey Irving wrote:
>
>> 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

Cool.  "git add -u && git add ." does exactly what I want.

This is only indirectly mentioned in the documentation.  If you think
it's reasonable to mention it more explicitly, I've attached a patch.

Thanks,
Geoffrey

[-- Attachment #2: 0001-Explicitly-note-in-documentation-that-git-add-u-rem.patch --]
[-- Type: application/octet-stream, Size: 989 bytes --]

From 698a0b7341647a0ce9e7abb36fe9357400e6bb59 Mon Sep 17 00:00:00 2001
From: Geoffrey Irving <irving@naml.us>
Date: Thu, 8 May 2008 10:00:04 -0700
Subject: [PATCH] Explicitly note in documentation that git-add -u removes files.

---
 Documentation/git-add.txt |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt
index 35e67a0..f7a8b03 100644
--- a/Documentation/git-add.txt
+++ b/Documentation/git-add.txt
@@ -74,7 +74,8 @@ OPTIONS
 	Update only files that git already knows about. This is similar
 	to what "git commit -a" does in preparation for making a commit,
 	except that the update is limited to paths specified on the
-	command line. If no paths are specified, all tracked files in the
+	command line. Files that are missing are removed (as if 'rm' had
+	been run). If no paths are specified, all tracked files in the
 	current directory and its subdirectories are updated.
 
 \--refresh::
-- 
1.5.4.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: automatically removing missing files beneath a directory
  2008-05-08 17:12   ` Geoffrey Irving
@ 2008-05-08 17:18     ` Jeff King
  2008-05-08 17:19       ` Geoffrey Irving
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff King @ 2008-05-08 17:18 UTC (permalink / raw)
  To: Geoffrey Irving; +Cc: git

On Thu, May 08, 2008 at 10:12:56AM -0700, Geoffrey Irving wrote:

> Cool.  "git add -u && git add ." does exactly what I want.
> 
> This is only indirectly mentioned in the documentation.  If you think
> it's reasonable to mention it more explicitly, I've attached a patch.

Yeah, the term "update" is not really defined there. I actually prefer
to mention it even earlier in the paragraph; does this make sense to
you?

diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt
index 35e67a0..e2389e3 100644
--- a/Documentation/git-add.txt
+++ b/Documentation/git-add.txt
@@ -71,7 +71,9 @@ OPTIONS
 	the specified filepatterns before exiting.
 
 -u::
-	Update only files that git already knows about. This is similar
+	Update only files that git already knows about, staging modified
+	content for commit and marking deleted files for removal. This
+	is similar
 	to what "git commit -a" does in preparation for making a commit,
 	except that the update is limited to paths specified on the
 	command line. If no paths are specified, all tracked files in the

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: automatically removing missing files beneath a directory
  2008-05-08 17:18     ` Jeff King
@ 2008-05-08 17:19       ` Geoffrey Irving
  0 siblings, 0 replies; 5+ messages in thread
From: Geoffrey Irving @ 2008-05-08 17:19 UTC (permalink / raw)
  To: Jeff King; +Cc: git

On Thu, May 8, 2008 at 10:18 AM, Jeff King <peff@peff.net> wrote:
> On Thu, May 08, 2008 at 10:12:56AM -0700, Geoffrey Irving wrote:
>
>> Cool.  "git add -u && git add ." does exactly what I want.
>>
>> This is only indirectly mentioned in the documentation.  If you think
>> it's reasonable to mention it more explicitly, I've attached a patch.
>
> Yeah, the term "update" is not really defined there. I actually prefer
> to mention it even earlier in the paragraph; does this make sense to
> you?
>
> diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt
> index 35e67a0..e2389e3 100644
> --- a/Documentation/git-add.txt
> +++ b/Documentation/git-add.txt
> @@ -71,7 +71,9 @@ OPTIONS
>        the specified filepatterns before exiting.
>
>  -u::
> -       Update only files that git already knows about. This is similar
> +       Update only files that git already knows about, staging modified
> +       content for commit and marking deleted files for removal. This
> +       is similar
>        to what "git commit -a" does in preparation for making a commit,
>        except that the update is limited to paths specified on the
>        command line. If no paths are specified, all tracked files in the

Yep, that's better than mine.

Geoffrey

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-05-08 17:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-08 16:39 automatically removing missing files beneath a directory Geoffrey Irving
2008-05-08 16:44 ` Jeff King
2008-05-08 17:12   ` Geoffrey Irving
2008-05-08 17:18     ` Jeff King
2008-05-08 17:19       ` Geoffrey Irving

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).