git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Octavio Alvarez" <alvarezp@alvarezp.ods.org>
To: "Ron Garret" <ron1@flownet.com>, git@vger.kernel.org
Subject: Re: What does git reset do?
Date: Tue, 02 Feb 2010 00:01:40 -0800	[thread overview]
Message-ID: <op.u7hpv8nd4oyyg1@localhost.localdomain> (raw)
In-Reply-To: <ron1-A2A2DE.23475601022010@news.gmane.org>

On Mon, 01 Feb 2010 23:47:56 -0800, Ron Garret <ron1@flownet.com> wrote:

> The docs say that git-reset:
>
> "Sets the current head to the specified commit..."

... without modifying your working copy if --soft, and modifying your  
working copy if --hard.

... and without switching branches (you want git checkout for that).

> So I tried this:
>
> [ron@mickey:~/devel/gittest]$ git branch
> * br1
>   master
> [ron@mickey:~/devel/gittest]$ git reset --soft master
>
>
> ...expecting HEAD to now point to master.  But it doesn't:

It actually does. HEAD (and br1) now point to [the commit pointed to by]  
master. Your working copy was left intact (because of --soft). Compare  
with "git checkout".

gitk --all is your friend to better understand this.

Your branch is still br1. It means, if you commit, br1 will advance, (not  
master). But, given your git reset, instead of committing over [the commit  
pointed to by previous] br1, you will commit over [the commit pointed to  
by] master.

Be careful though, you might lose commits with git reset.

> [ron@mickey:~/devel/gittest]$ git branch
> * br1
>   master
> [ron@mickey:~/devel/gittest]$ more .git/HEAD
> ref: refs/heads/br1
>
>
> So... what does git reset do?

Sets the current head (and branch, if not detached) to the specified  
commit...

-- 
--
Octavio.

  reply	other threads:[~2010-02-02  8:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-02  7:47 What does git reset do? Ron Garret
2010-02-02  8:01 ` Octavio Alvarez [this message]
2010-02-02  8:24   ` Ron Garret
2010-02-02  8:37     ` Octavio Alvarez
2010-02-02 15:30 ` Jakub Narebski

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=op.u7hpv8nd4oyyg1@localhost.localdomain \
    --to=alvarezp@alvarezp.ods.org \
    --cc=git@vger.kernel.org \
    --cc=ron1@flownet.com \
    /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).