git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Delete a commit
@ 2009-12-19 23:39 Bertram Scharpf
  2009-12-19 23:43 ` James P. Howard, II
  2009-12-20  0:06 ` Johan 't Hart
  0 siblings, 2 replies; 8+ messages in thread
From: Bertram Scharpf @ 2009-12-19 23:39 UTC (permalink / raw)
  To: git

Hi,

I fetched a line from the shell's history and accidentally hit
enter before editing it. Then I had commited some work that was
not completed. Is there a way to get rid of that commit as if it
never were there?

Thanks in advance.

Bertram


-- 
Bertram Scharpf
Stuttgart, Deutschland/Germany
http://www.bertram-scharpf.de

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Delete a commit
  2009-12-19 23:39 Delete a commit Bertram Scharpf
@ 2009-12-19 23:43 ` James P. Howard, II
  2009-12-20  0:06 ` Johan 't Hart
  1 sibling, 0 replies; 8+ messages in thread
From: James P. Howard, II @ 2009-12-19 23:43 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 433 bytes --]

On Sun, Dec 20, 2009 at 12:39:57AM +0100, Bertram Scharpf wrote:

> I fetched a line from the shell's history and accidentally hit
> enter before editing it. Then I had commited some work that was
> not completed. Is there a way to get rid of that commit as if it
> never were there?

If you have committed nothing else in the interim, 

  git reset HEAD~1

James

-- 
James P. Howard, II, MPA MBCS
jh@jameshoward.us

[-- Attachment #2: Type: application/pgp-signature, Size: 455 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Delete a commit
  2009-12-19 23:39 Delete a commit Bertram Scharpf
  2009-12-19 23:43 ` James P. Howard, II
@ 2009-12-20  0:06 ` Johan 't Hart
  2009-12-20  0:43   ` Bertram Scharpf
  1 sibling, 1 reply; 8+ messages in thread
From: Johan 't Hart @ 2009-12-20  0:06 UTC (permalink / raw)
  To: git

Bertram Scharpf schreef:
> Hi,
> 
> I fetched a line from the shell's history and accidentally hit
> enter before editing it. Then I had commited some work that was
> not completed. Is there a way to get rid of that commit as if it
> never were there?

Try:
git reset --soft HEAD~1

You could also:
git commit --amend ...

when you realy finish the commit.

> 
> Thanks in advance.
> 
> Bertram
> 
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Delete a commit
  2009-12-20  0:06 ` Johan 't Hart
@ 2009-12-20  0:43   ` Bertram Scharpf
  2009-12-20  8:37     ` Pascal Obry
  2009-12-21 17:49     ` Johan 't Hart
  0 siblings, 2 replies; 8+ messages in thread
From: Bertram Scharpf @ 2009-12-20  0:43 UTC (permalink / raw)
  To: git

Hi,

Am Sonntag, 20. Dez 2009, 01:06:46 +0100 schrieb Johan 't Hart:
> Bertram Scharpf schreef:
>> I fetched a line from the shell's history and accidentally hit
>> enter before editing it. Then I had commited some work that was
>> not completed. Is there a way to get rid of that commit as if it
>> never were there?
>
> Try:
> git reset --soft HEAD~1
>
> You could also:
> git commit --amend ...

  % git fsck --lost-found
  dangling commit 6abc221327e896c850c56dafae92277bcfe68e2b

It is still there. This is the one I want to delete.

Bertram


-- 
Bertram Scharpf
Stuttgart, Deutschland/Germany
http://www.bertram-scharpf.de

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Delete a commit
  2009-12-20  0:43   ` Bertram Scharpf
@ 2009-12-20  8:37     ` Pascal Obry
  2009-12-21 17:49     ` Johan 't Hart
  1 sibling, 0 replies; 8+ messages in thread
From: Pascal Obry @ 2009-12-20  8:37 UTC (permalink / raw)
  To: git

Le 20/12/2009 01:43, Bertram Scharpf a écrit :
>   % git fsck --lost-found
>   dangling commit 6abc221327e896c850c56dafae92277bcfe68e2b
> 
> It is still there. This is the one I want to delete.

Well, it is deleted (not accessible from any ref). It will be purged
from the repository at some point after a "git gc".

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|    http://www.obry.net  -  http://v2p.fr.eu.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver keys.gnupg.net --recv-key F949BD3B

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Delete a commit
  2009-12-20  0:43   ` Bertram Scharpf
  2009-12-20  8:37     ` Pascal Obry
@ 2009-12-21 17:49     ` Johan 't Hart
  2009-12-21 18:17       ` Andreas Schwab
  2009-12-21 21:01       ` Bertram Scharpf
  1 sibling, 2 replies; 8+ messages in thread
From: Johan 't Hart @ 2009-12-21 17:49 UTC (permalink / raw)
  To: git

Bertram Scharpf schreef:
> Hi,

>   % git fsck --lost-found
>   dangling commit 6abc221327e896c850c56dafae92277bcfe68e2b
> 
> It is still there. This is the one I want to delete.

It is not in the history of any head anymore, so you could consider it 
deleted. ('git log' does not show this commit)

If you want to prune unreferenced objects, try:
git prune

('git help prune' for options)


> Bertram
> 
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Delete a commit
  2009-12-21 17:49     ` Johan 't Hart
@ 2009-12-21 18:17       ` Andreas Schwab
  2009-12-21 21:01       ` Bertram Scharpf
  1 sibling, 0 replies; 8+ messages in thread
From: Andreas Schwab @ 2009-12-21 18:17 UTC (permalink / raw)
  To: Johan 't Hart; +Cc: git

Johan 't Hart <johanthart@gmail.com> writes:

> Bertram Scharpf schreef:
>> Hi,
>
>>   % git fsck --lost-found
>>   dangling commit 6abc221327e896c850c56dafae92277bcfe68e2b
>>
>> It is still there. This is the one I want to delete.
>
> It is not in the history of any head anymore, so you could consider it
> deleted. ('git log' does not show this commit)

Except through the reflog, most likely.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Delete a commit
  2009-12-21 17:49     ` Johan 't Hart
  2009-12-21 18:17       ` Andreas Schwab
@ 2009-12-21 21:01       ` Bertram Scharpf
  1 sibling, 0 replies; 8+ messages in thread
From: Bertram Scharpf @ 2009-12-21 21:01 UTC (permalink / raw)
  To: git

Hi,

Am Montag, 21. Dez 2009, 18:49:36 +0100 schrieb Johan 't Hart:
> Bertram Scharpf schreef:
>
>>   % git fsck --lost-found
>>   dangling commit 6abc221327e896c850c56dafae92277bcfe68e2b
>> It is still there. This is the one I want to delete.
>
> It is not in the history of any head anymore, so you could consider it 
> deleted. ('git log' does not show this commit)
>
> If you want to prune unreferenced objects, try:
> git prune
>
> ('git help prune' for options)

In the meantime I detected the gc.pruneExpire config variable. I
didn't get that to work on all versions that I have installed on
different machines, but I just wanted to understand what has to
happen with the commit.

Thank you!

Bertram


-- 
Bertram Scharpf
Stuttgart, Deutschland/Germany
http://www.bertram-scharpf.de

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-12-21 21:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-19 23:39 Delete a commit Bertram Scharpf
2009-12-19 23:43 ` James P. Howard, II
2009-12-20  0:06 ` Johan 't Hart
2009-12-20  0:43   ` Bertram Scharpf
2009-12-20  8:37     ` Pascal Obry
2009-12-21 17:49     ` Johan 't Hart
2009-12-21 18:17       ` Andreas Schwab
2009-12-21 21:01       ` Bertram Scharpf

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