{"thread":{"id":"19436","subject":"git reset --hard and uncommitted files in index","startedAt":"2009-05-22T02:32:36Z","lastAt":"2009-05-22T10:50:40Z","messageCount":3,"participants":["Thomas Guyot-Sionnest","Johannes Sixt","Sverre Rabbelier"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"114445","messageId":"gv52s4$e7h$1@ger.gmane.org","threadId":"19436","inReplyTo":null,"subject":"git reset --hard and uncommitted files in index","fromName":"Thomas Guyot-Sionnest","fromEmail":"dermoth@aei.ca","sentAt":"2009-05-22T02:32:36Z","receivedAt":"2009-05-22T02:32:36Z","isPatch":false,"sender":{"key":"dermoth@aei.ca","avatar":null},"body":"Hi,\n\nToday I was working on a script that modify many files on a repository,\ntherefore during testing phase I needed to reset --hard to get back to\nthe last commit. This operation does not affect untracked files.\n\nSince i was going to commit the script, at some point I decided to add\nit to the index so I could track/revert changes to it. On the next reset\nGit deleted the script.\n\nFortunately \"git add\" creates an object that I could easily recover\n(thanks to wereHamster on #git for pointing that out), however I was\nwondering if it's really the desired behavior to *delete* a file that\nhave been added to the index but isn't on the previous commit? Shouldn't\ngit just unstage it?\n\n--\nThomas\n"},{"id":"114449","messageId":"4A1649A9.5090606@viscovery.net","threadId":"19436","inReplyTo":"gv52s4$e7h$1@ger.gmane.org","subject":"Re: git reset --hard and uncommitted files in index","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2009-05-22T06:43:53Z","receivedAt":"2009-05-22T06:43:53Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Thomas Guyot-Sionnest schrieb:\n> Today I was working on a script that modify many files on a repository,\n> therefore during testing phase I needed to reset --hard to get back to\n> the last commit. This operation does not affect untracked files.\n> \n> Since i was going to commit the script, at some point I decided to add\n> it to the index so I could track/revert changes to it. On the next reset\n> Git deleted the script.\n> \n> Fortunately \"git add\" creates an object that I could easily recover\n> (thanks to wereHamster on #git for pointing that out), however I was\n> wondering if it's really the desired behavior to *delete* a file that\n> have been added to the index but isn't on the previous commit? Shouldn't\n> git just unstage it?\n\nNo, the behavior is by design. Its purpose is to return the working\ndirectory to a clean slate. For example, after a conflicted merge the\nmerged branch may have brought new files, but you wouldn't want to keep\nthem around after the cleanup.\n\n'git reset --hard' is \"do what I say\", not \"do what I mean\". ;-)\n\n-- Hannes\n"},{"id":"114460","messageId":"fabb9a1e0905220350i12d30d17udf078ec2ff76513a@mail.gmail.com","threadId":"19436","inReplyTo":"gv52s4$e7h$1@ger.gmane.org","subject":"Re: git reset --hard and uncommitted files in index","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2009-05-22T10:50:40Z","receivedAt":"2009-05-22T10:50:40Z","isPatch":false,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"Heya,\n\nOn Fri, May 22, 2009 at 04:32, Thomas Guyot-Sionnest <dermoth@aei.ca> wrote:\n> Shouldn't git just unstage it?\n\nYou can do that too, 'git reset && git reset --hard' will not touch\nuntracked files. The first will unstage all your changes, the second\nwill blow away all changes to tracked files.\n\n-- \nCheers,\n\nSverre Rabbelier\n"}]}