Re: What does git reset do?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 01 Feb 2010 23:47:56 -0800, Ron Garret <ron1@xxxxxxxxxxx> 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.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]