git reset HEAD~1
Gedare Bloom
gedare at rtems.org
Mon Feb 13 17:10:04 UTC 2012
I've updated the wiki with these new examples. I think there is a
difference when you use a ~ (tilda) and a - (hyphen). Now the wiki
avoids using hyphens.
On Mon, Feb 13, 2012 at 10:22 AM, Cláudio Silva
<claudiodcsilva at gmail.com> wrote:
> Hi,
>
> I think that description is wrong. Let's try a longer description
> (hopefully correct) of git reset:
>
> "git reset HEAD~" will undo the last commit and unstage those changes.
> Your working directory will remain the same, therefore a "git status"
> will yield any changes you made plus the changes made in your last
> commit. This can be used to fix the last commit. You will need to add
> the files again.
>
> "git reset --soft HEAD~" will just undo the last commit.The changes
> from last commit will still be staged (just as if you finished git'
> adding them). This can be used to amend the last commit (e.g. I
> forgot to add a file to the last commit).
>
> "git reset --hard HEAD~" will revert everything, including the working
> directory, to the previous commit. This is dangerous and can lead to
> you losing all your changes.
>
> "git reset HEAD" will unstage any change. This is used to revert a
> wrong git add. (e.g. I added a file that shouldn't be there, but i
> haven't 'commited')
>
> "git reset --hard HEAD" will revert your working directory to a HEAD
> state. (You will lose any change you made to files after the last
> commit). This is used when you just want to destroy all changes you
> made since the last commit.
>
> Regards,
> Cláudio
>
> On Mon, Feb 13, 2012 at 2:13 PM, Ralf Corsepius
> <ralf.corsepius at rtems.org> wrote:
>> Hi,
>>
>> http://wiki.rtems.org/wiki/index.php/Git
>>
>> tells:
>>
>> git reset HEAD-1
>>
>> Removes the last 1 (or any other number you put) commit from the current
>> branch. git reset should only be used on local branches that no one else is
>> accessing remotely. This is a very powerful and tricky command; A good
>> description of what it enables to do can be found here
>>
>>
>> Either there is a language barrier causing me to misunderstand this sentence
>> or this sentence doesn't seem right:
>>
>> git reset HEAD ... removes the last commit
>> git reset HEAD~1 ... remove the last 2 commits
>>
>> The human factor had just hit me (I needed to revert my last commit),
>> causing me to exercise this to trip over this.
>>
>> Ralf
>>
>>
>> _______________________________________________
>> rtems-devel mailing list
>> rtems-devel at rtems.org
>> http://www.rtems.org/mailman/listinfo/rtems-devel
>
> _______________________________________________
> rtems-devel mailing list
> rtems-devel at rtems.org
> http://www.rtems.org/mailman/listinfo/rtems-devel
More information about the devel
mailing list