git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Dale Worley <worley@alum.mit.edu>
To: git@vger.kernel.org
Subject: Re: Git reset --hard with staged changes
Date: Tue, 10 Jun 2014 01:03:09 +0000 (UTC)	[thread overview]
Message-ID: <loom.20140610T025754-449@post.gmane.org> (raw)
In-Reply-To: CANWD=rVB249Vu1QMk64V+FxfCfJPzxqZgCfyEuixJJ_iKoTLPQ@mail.gmail.com

From: Pierre-François CLEMENT <likeyn <at> gmail.com>
> You create a new (untracked) file.
> You use git-reset's hard mode to go one commit back, the new
> (untracked) file's still there.
> You add/stage that new file.
> You use git-reset's hard mode again to go one commit back, and the new
> untracked file you just staged gets deleted.
> 
> Also, according to Git-scm
> (http://git-scm.com/book/en/Git-Basics-Recording-Changes-to-the-Repository):
> 
> "Tracked files are files that were in the last snapshot [...].
> Untracked files are everything else."
> 
> So it seems to me like staged untracked files shouldn't be considered
> as tracked files, and thus shouldn't be removed. Or maybe, git-reset's
> hard mode should always delete everything including untracked files?
> It would also make sense, given the numerous modes it has.

There's a core question that must be answered:  What, *exactly*, is a
"tracked file"?

If you look at that passage in the book, it continues:

"Tracked files are files that were in the last snapshot; they can be
unmodified, modified, or staged. Untracked files are everything else — any
files in your working directory that were not in your last snapshot and are
not in your staging area."

But if you look carefully, that passage gives two definitions of "untracked
files", and *they don't agree*, specifically in the case of a file that is
in the index but not in the base commit.  And that's the case we're considering.

To fix this, you've got to figure out what the definition of "tracked file"
is supposed to be, and then ensure that everything (code and documentation)
is consistent with that.

(As far as I can tell from Git's behavior, the definition of tracked file is
"any file that is in the base commit or in the index".  Based on that
definition, "git reset --hard" is working as documented.)

Dale

  parent reply	other threads:[~2014-06-10  1:15 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CANWD=rWmzgAwTp=E_1=th0Myk-dh4m5Y9PE3=fpHeirsVVQKwQ@mail.gmail.com>
2014-06-09 11:24 ` Git reset --hard with staged changes Pierre-François CLEMENT
2014-06-09 14:04   ` David Kastrup
2014-06-09 23:22     ` Pierre-François CLEMENT
2014-06-09 23:28       ` Junio C Hamano
2014-06-10 14:59         ` Pierre-François CLEMENT
2014-06-10 15:27           ` David Kastrup
2014-06-10 16:30             ` Pierre-François CLEMENT
2014-06-10  1:03       ` Dale Worley [this message]
2014-06-10  5:44         ` Junio C Hamano
2016-05-23  0:55 Yotam Gingold
2016-05-23 17:05 ` Junio C Hamano
2016-05-23 19:31 ` Christian Couder
2016-05-23 21:16   ` Junio C Hamano
2016-05-24  6:20     ` Christian Couder
2016-05-30  5:07       ` Yotam Gingold
2016-05-31  6:02         ` Junio C Hamano
2016-05-31  6:41           ` Christian Couder

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=loom.20140610T025754-449@post.gmane.org \
    --to=worley@alum.mit.edu \
    --cc=git@vger.kernel.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).