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

Re: abouy git reset command

From
Jakub Narebski <jnareb@gmail.com>
Date
May 13, 2008, 08:33 UTC
Message-ID
<m3zlqu38ny.fsf@localhost.localdomain>
In-Reply-To
<17202423.post@talk.nabble.com>
amishera <amishera2007@gmail.com> writes:
Show 16 quoted lines
> I just want to make sure whether my understanding of that command is correct
> or not. I have 3 basic requirements:
> 
> 1. I have changed something after the commits and I think those are wrong.
> So I want to undo all changes and the working directory should reflect last
> commit:
> 
> git reset --hard HEAD
> 
> 2. I have some changes in the index and I want undo them.
> 
> git reset HEAD
> 
> 3. I just want to undo the last commit but not the working tree:
> 
> git reset HEAD^
If you mean by "undo last commit" reset HEAD pointer and index state,
then yes.
 
Show 19 quoted lines
> If they are correct commands please let me know. 
> 
> Besides in the man page for git reset it is mentioned:
> 
> git-reset - Reset current HEAD to the specified state
> 
> Which means it is supposed to work with commits. But why is the same
> command work in case 2 and case 3 above?
> 
> Moreover, can any body tell me the use of
> 
> git reset --soft
> 
> The following language is confusing:
> 
> --soft
> 
>     Does not touch the index file nor the working tree at all, but
>     requires them to be in a good order.

git-reset is all about setting the HEAD pointer, or to be more exact to set current branch (current head) reference. There are three degrees of it:

 --soft changes only current HEAD
 --mixed (default) changes current HEAD and index file
 --hard changes current HEAD, index file and working tree

If you don't give <commit-ish>, git-reset defaults to HEAD, i.e. current version. Thus "git reset --soft" is no-op, it does do nothing.

-- 
Jakub Narebski
Poland
ShadeHawk on #git
Previous: amisheraNext: David Tweed
Message 2 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.