{"thread":{"id":"13499","subject":"abouy git reset command","startedAt":"2008-05-13T07:07:45Z","lastAt":"2008-05-13T12:34:56Z","messageCount":3,"participants":["amishera","Jakub Narebski","David Tweed"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"76839","messageId":"17202423.post@talk.nabble.com","threadId":"13499","inReplyTo":null,"subject":"abouy git reset command","fromName":"amishera","fromEmail":"amishera2007@gmail.com","sentAt":"2008-05-13T07:07:45Z","receivedAt":"2008-05-13T07:07:45Z","isPatch":false,"sender":{"key":"amishera2007@gmail.com","avatar":null},"body":"\nHi,\nI just want to make sure whether my understanding of that command is correct\nor not. I have 3 basic requirements:\n\n1. I have changed something after the commits and I think those are wrong.\nSo I want to undo all changes and the working directory should reflect last\ncommit:\n\ngit reset --hard HEAD\n\n2. I have some changes in the index and I want undo them.\n\ngit reset HEAD\n\n3. I just want to undo the last commit but not the working tree:\n\ngit reset HEAD^\n\nIf they are correct commands please let me know. \n\nBesides in the man page for git reset it is mentioned:\n\ngit-reset - Reset current HEAD to the specified state\n\nWhich means it is supposed to work with commits. But why is the same command\nwork in case 2 and case 3 above? \n\nMoreover, can any body tell me the use of\n\ngit reset --soft\n\nThe following language is confusing:\n\n--soft\n\n    Does not touch the index file nor the working tree at all, but requires\nthem to be in a good order.\n\nThanks in advance.\n-- \nView this message in context: http://www.nabble.com/abouy-git-reset-command-tp17202423p17202423.html\nSent from the git mailing list archive at Nabble.com.\n"},{"id":"76842","messageId":"m3zlqu38ny.fsf@localhost.localdomain","threadId":"13499","inReplyTo":"17202423.post@talk.nabble.com","subject":"Re: abouy git reset command","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-05-13T08:33:37Z","receivedAt":"2008-05-13T08:33:37Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"amishera <amishera2007@gmail.com> writes:\n\n> I just want to make sure whether my understanding of that command is correct\n> or not. I have 3 basic requirements:\n> \n> 1. I have changed something after the commits and I think those are wrong.\n> So I want to undo all changes and the working directory should reflect last\n> commit:\n> \n> git reset --hard HEAD\n> \n> 2. I have some changes in the index and I want undo them.\n> \n> git reset HEAD\n> \n> 3. I just want to undo the last commit but not the working tree:\n> \n> git reset HEAD^\n\nIf you mean by \"undo last commit\" reset HEAD pointer and index state,\nthen yes.\n \n> If they are correct commands please let me know. \n> \n> Besides in the man page for git reset it is mentioned:\n> \n> git-reset - Reset current HEAD to the specified state\n> \n> Which means it is supposed to work with commits. But why is the same\n> command work in case 2 and case 3 above?\n> \n> Moreover, can any body tell me the use of\n> \n> git reset --soft\n> \n> The following language is confusing:\n> \n> --soft\n> \n>     Does not touch the index file nor the working tree at all, but\n>     requires them to be in a good order.\n\ngit-reset is all about setting the HEAD pointer, or to be more exact\nto set current branch (current head) reference.  There are three\ndegrees of it:\n\n --soft changes only current HEAD\n --mixed (default) changes current HEAD and index file\n --hard changes current HEAD, index file and working tree\n\nIf you don't give <commit-ish>, git-reset defaults to HEAD,\ni.e. current version.  Thus \"git reset --soft\" is no-op, it does do\nnothing.\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"76868","messageId":"e1dab3980805130534w42ce098qf2ffe2fc89fab98b@mail.gmail.com","threadId":"13499","inReplyTo":"17202423.post@talk.nabble.com","subject":"Re: abouy git reset command","fromName":"David Tweed","fromEmail":"david.tweed@gmail.com","sentAt":"2008-05-13T12:34:56Z","receivedAt":"2008-05-13T12:34:56Z","isPatch":false,"sender":{"key":"david.tweed@gmail.com","avatar":null},"body":"On Tue, May 13, 2008 at 8:07 AM, amishera <amishera2007@gmail.com> wrote:\n> Moreover, can any body tell me the use of\n>\n> git reset --soft\n\nJakub answered about \"git reset --soft\" on its own, so I'll just\nmention the situation I use, say, \"git reset --soft HEAD~5\" which is:\nsuppose you realise that you made a really bad mistake 5 commits ago\n(say some obscure bug that could cause data loss) and you've just\ndiscovered and fixed it in your working tree (checking in bits to the\nindex). You don't want to risk ever running a version of your program\nbuilt from any of those commits. What you really _ought_ to do is\nessentially redo those 5 commits removing the bug, but depending how\nrigorous and time constrained your development is you might just want\nto commit your new fixed state with one big change log. \"git reset\n--soft HEAD~5\" moves HEAD back five commits but leaves your working\ntree and index alone, so the next \"git commit\" will commit your fixed\ncurrent state after the new HEAD. It's clearly not what you want to do\nif you're working in a careful development team, but I find it useful\non rare occasions.\n\n-- \ncheers, dave tweed__________________________\ndavid.tweed@gmail.com\nRm 124, School of Systems Engineering, University of Reading.\n\"while having code so boring anyone can maintain it, use Python.\" --\nattempted insult seen on slashdot\n"}]}