From: Carl Worth <cworth@cworth.org>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org
Subject: Re: How to commit removed file?
Date: Thu, 11 Jan 2007 17:40:09 -0800 [thread overview]
Message-ID: <877ivtxbt2.wl%cworth@cworth.org> (raw)
In-Reply-To: <7vzm8wapdv.fsf@assigned-by-dhcp.cox.net>
[-- Attachment #1: Type: text/plain, Size: 2275 bytes --]
On Fri, 05 Jan 2007 17:57:16 -0800, Junio C Hamano wrote:
> Carl Worth <cworth@cworth.org> 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
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
next prev parent reply other threads:[~2007-01-12 1:42 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-31 10:24 How to commit removed file? Michael S. Tsirkin
2006-12-31 15:06 ` Johannes Schindelin
2007-01-02 20:10 ` Michael S. Tsirkin
2007-01-02 21:12 ` Johannes Schindelin
2007-01-02 21:40 ` Junio C Hamano
2007-01-02 22:13 ` Jakub Narebski
2007-01-02 22:20 ` Johannes Schindelin
2007-01-03 0:55 ` Carl Worth
2007-01-06 1:57 ` Junio C Hamano
2007-01-12 1:40 ` Carl Worth [this message]
2007-01-12 10:42 ` Jakub Narebski
2007-01-03 6:06 ` Michael S. Tsirkin
2007-01-03 6:51 ` Junio C Hamano
2007-01-03 7:14 ` Junio C Hamano
2007-01-04 17:41 ` Michael S. Tsirkin
2007-01-02 21:49 ` Juergen Ruehle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877ivtxbt2.wl%cworth@cworth.org \
--to=cworth@cworth.org \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).