git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: abouy git reset command

From
DTDavid Tweed <david.tweed@gmail.com>
Date
May 13, 2008, 12:34 UTC
Message-ID
<e1dab3980805130534w42ce098qf2ffe2fc89fab98b@mail.gmail.com>
In-Reply-To
<17202423.post@talk.nabble.com>
On Tue, May 13, 2008 at 8:07 AM, amishera <amishera2007@gmail.com> wrote:
> Moreover, can any body tell me the use of
>
> git reset --soft

Jakub answered about "git reset --soft" on its own, so I'll just mention the situation I use, say, "git reset --soft HEAD~5" which is: suppose you realise that you made a really bad mistake 5 commits ago (say some obscure bug that could cause data loss) and you've just discovered and fixed it in your working tree (checking in bits to the index). You don't want to risk ever running a version of your program built from any of those commits. What you really _ought_ to do is essentially redo those 5 commits removing the bug, but depending how rigorous and time constrained your development is you might just want to commit your new fixed state with one big change log. "git reset --soft HEAD~5" moves HEAD back five commits but leaves your working tree and index alone, so the next "git commit" will commit your fixed current state after the new HEAD. It's clearly not what you want to do if you're working in a careful development team, but I find it useful on rare occasions.

-- 
cheers, dave tweed__________________________
david.tweed@gmail.com
Rm 124, School of Systems Engineering, University of Reading.
"while having code so boring anyone can maintain it, use Python." --
attempted insult seen on slashdot
Previous: Jakub Narebski
Message 3 of 3 in “abouy git reset command”
  1. amisheraMay 13, 2008
  2. Jakub NarebskiMay 13, 2008
  3. David TweedMay 13, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.