git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git reset --hard and uncommitted files in index
@ 2009-05-22  2:32 Thomas Guyot-Sionnest
  2009-05-22  6:43 ` Johannes Sixt
  2009-05-22 10:50 ` Sverre Rabbelier
  0 siblings, 2 replies; 3+ messages in thread
From: Thomas Guyot-Sionnest @ 2009-05-22  2:32 UTC (permalink / raw)
  To: git

Hi,

Today I was working on a script that modify many files on a repository,
therefore during testing phase I needed to reset --hard to get back to
the last commit. This operation does not affect untracked files.

Since i was going to commit the script, at some point I decided to add
it to the index so I could track/revert changes to it. On the next reset
Git deleted the script.

Fortunately "git add" creates an object that I could easily recover
(thanks to wereHamster on #git for pointing that out), however I was
wondering if it's really the desired behavior to *delete* a file that
have been added to the index but isn't on the previous commit? Shouldn't
git just unstage it?

--
Thomas

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

* Re: git reset --hard and uncommitted files in index
  2009-05-22  2:32 git reset --hard and uncommitted files in index Thomas Guyot-Sionnest
@ 2009-05-22  6:43 ` Johannes Sixt
  2009-05-22 10:50 ` Sverre Rabbelier
  1 sibling, 0 replies; 3+ messages in thread
From: Johannes Sixt @ 2009-05-22  6:43 UTC (permalink / raw)
  To: Thomas Guyot-Sionnest; +Cc: git

Thomas Guyot-Sionnest schrieb:
> Today I was working on a script that modify many files on a repository,
> therefore during testing phase I needed to reset --hard to get back to
> the last commit. This operation does not affect untracked files.
> 
> Since i was going to commit the script, at some point I decided to add
> it to the index so I could track/revert changes to it. On the next reset
> Git deleted the script.
> 
> Fortunately "git add" creates an object that I could easily recover
> (thanks to wereHamster on #git for pointing that out), however I was
> wondering if it's really the desired behavior to *delete* a file that
> have been added to the index but isn't on the previous commit? Shouldn't
> git just unstage it?

No, the behavior is by design. Its purpose is to return the working
directory to a clean slate. For example, after a conflicted merge the
merged branch may have brought new files, but you wouldn't want to keep
them around after the cleanup.

'git reset --hard' is "do what I say", not "do what I mean". ;-)

-- Hannes

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

* Re: git reset --hard and uncommitted files in index
  2009-05-22  2:32 git reset --hard and uncommitted files in index Thomas Guyot-Sionnest
  2009-05-22  6:43 ` Johannes Sixt
@ 2009-05-22 10:50 ` Sverre Rabbelier
  1 sibling, 0 replies; 3+ messages in thread
From: Sverre Rabbelier @ 2009-05-22 10:50 UTC (permalink / raw)
  To: Thomas Guyot-Sionnest; +Cc: git

Heya,

On Fri, May 22, 2009 at 04:32, Thomas Guyot-Sionnest <dermoth@aei.ca> wrote:
> Shouldn't git just unstage it?

You can do that too, 'git reset && git reset --hard' will not touch
untracked files. The first will unstage all your changes, the second
will blow away all changes to tracked files.

-- 
Cheers,

Sverre Rabbelier

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

end of thread, other threads:[~2009-05-22 10:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-22  2:32 git reset --hard and uncommitted files in index Thomas Guyot-Sionnest
2009-05-22  6:43 ` Johannes Sixt
2009-05-22 10:50 ` Sverre Rabbelier

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).