git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: amishera <amishera2007@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: abouy git reset command
Date: Tue, 13 May 2008 01:33:37 -0700 (PDT)	[thread overview]
Message-ID: <m3zlqu38ny.fsf@localhost.localdomain> (raw)
In-Reply-To: <17202423.post@talk.nabble.com>

amishera <amishera2007@gmail.com> writes:

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

  reply	other threads:[~2008-05-13  8:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-13  7:07 abouy git reset command amishera
2008-05-13  8:33 ` Jakub Narebski [this message]
2008-05-13 12:34 ` David Tweed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3zlqu38ny.fsf@localhost.localdomain \
    --to=jnareb@gmail.com \
    --cc=amishera2007@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).