From: Carl Worth Subject: Re: How to commit removed file? Date: Thu, 11 Jan 2007 17:40:09 -0800 Message-ID: <877ivtxbt2.wl%cworth@cworth.org> References: <20061231102444.GD26552@mellanox.co.il> <20070102201041.GB10451@mellanox.co.il> <7vfyatt8di.fsf@assigned-by-dhcp.cox.net> <87lkklgc8v.wl%cworth@cworth.org> <7vzm8wapdv.fsf@assigned-by-dhcp.cox.net> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: multipart/signed; boundary="pgp-sign-Multipart_Thu_Jan_11_17:40:09_2007-1"; micalg=pgp-sha1; protocol="application/pgp-signature" Content-Transfer-Encoding: 7bit Cc: git@vger.kernel.org X-From: git-owner@vger.kernel.org Fri Jan 12 02:42:39 2007 Return-path: Envelope-to: gcvg-git@gmane.org Received: from vger.kernel.org ([209.132.176.167]) by lo.gmane.org with esmtp (Exim 4.50) id 1H5BRD-0003lt-HQ for gcvg-git@gmane.org; Fri, 12 Jan 2007 02:42:35 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932822AbXALBmO (ORCPT ); Thu, 11 Jan 2007 20:42:14 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1030304AbXALBmO (ORCPT ); Thu, 11 Jan 2007 20:42:14 -0500 Received: from mx1.redhat.com ([66.187.233.31]:52336 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932640AbXALBmM (ORCPT ); Thu, 11 Jan 2007 20:42:12 -0500 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11.20060308/8.12.11) with ESMTP id l0C1g7SD029584; Thu, 11 Jan 2007 20:42:07 -0500 Received: from mail.boston.redhat.com (mail.boston.redhat.com [172.16.76.12]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id l0C1g2Oj032751; Thu, 11 Jan 2007 20:42:02 -0500 Received: from raht.cworth.org (sebastian-int.corp.redhat.com [172.16.52.221]) by mail.boston.redhat.com (8.12.11.20060308/8.12.11) with ESMTP id l0C1g1MK004947; Thu, 11 Jan 2007 20:42:01 -0500 To: Junio C Hamano In-Reply-To: <7vzm8wapdv.fsf@assigned-by-dhcp.cox.net> User-Agent: Wanderlust/2.14.0 (Africa) Emacs/21.4 Mule/5.0 (SAKAKI) Sender: git-owner@vger.kernel.org Precedence: bulk X-Mailing-List: git@vger.kernel.org Archived-At: --pgp-sign-Multipart_Thu_Jan_11_17:40:09_2007-1 Content-Type: text/plain; charset=US-ASCII On Fri, 05 Jan 2007 17:57:16 -0800, Junio C Hamano wrote: > Carl Worth writes: > > On Tue, 02 Jan 2007 13:40:41 -0800, Junio C Hamano wrote: > >> Personally I never saw the point of having "git rm". Maybe we > >> should remove it to prevent this confusion from happening. > > > > The one place where it's really "necessary", (as opposed to some users > > just expecting it to be there), is to "undo" a git-add, (and I mean a > > git-add that actually adds a new path to the index, not one of these > > newfangled git-adds that simply updates content for an existing path). > > "git reset" (i.e. --mixed) is the way to revert the index back > to HEAD and start over. But that's a lot more than I want. Here's something like one of the original use cases that I hit and had in mind (as best I recall) that motivated be to write the initial git-rm command. It was something like adding a feature and a new test-case at the same time: git update-index src/Makefile git update-index src/some-feature.c git add test/feature-test.c # Hmm, wait, it'd be cleaner to add test/feature-test.c as a separate # commit. How can I undo that "git add" I just did? So, at this point, I could git-reset and start over, but I wanted a way to undo just the "add" and leave all the other updates still in the index. It's not really all that important to be able to undo the add, (there's not really a corresponding way to selectively undo the other update-index calls without using git-reset for everything). But now that I tried this case with a recent git (2a3a3c247) for which git-rm does working-tree removal without -f, I see that it does irretrievably destroy information in this case: $ echo "important stuff" > new-file $ git add new-file $ git rm new-file This now deletes new-file from the working tree and there's no copy of the data inside git. The old git-rm would just return the file to it's "untracked" state in this case. I had thought the safety check was going to be that the index state matched the HEAD state before git-rm would delete from the working tree. (Note, that I definitely agree that it's an improvement that git-rm does delete the working-tree file when the working-tree and index and HEAD all have the same content.) -Carl --pgp-sign-Multipart_Thu_Jan_11_17:40:09_2007-1 Content-Type: application/pgp-signature Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) iD8DBQBFpub56JDdNq8qSWgRAizbAJ48wAFNp8SSA/h3B8ITVE/pWxcytwCeIJqc 3JPR6PcZK0BlhTCdNCbIe9E= =ISxP -----END PGP SIGNATURE----- --pgp-sign-Multipart_Thu_Jan_11_17:40:09_2007-1--