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

Re: What does git reset do?

From
OAOctavio Alvarez <alvarezp@alvarezp.ods.org>
Date
Feb 2, 2010, 08:01 UTC
Message-ID
<op.u7hpv8nd4oyyg1@localhost.localdomain>
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).
Show 9 quoted lines
> 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.
Show 8 quoted lines
> [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.
Previous: Ron GarretNext: Ron Garret
Message 2 of 5 in “What does git reset do?”
  1. Ron GarretFeb 2, 2010
  2. Octavio AlvarezFeb 2, 2010
  3. Ron GarretFeb 2, 2010
  4. Octavio AlvarezFeb 2, 2010
  5. Jakub NarebskiFeb 2, 2010

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.