home | list info | list archive | date index | thread index

[OCLUG-Tech] can one use "git gc" to *immediately* remove a dangling commit?

  • Subject: [OCLUG-Tech] can one use "git gc" to *immediately* remove a dangling commit?
  • From: "Robert P. J. Day" <rpjday [ at ] crashcourse [ dot ] ca>
  • Date: Tue, 19 May 2015 08:49:12 -0400 (EDT)
  ah, more git pedantry ... as a demo of how one identifies and
removes dangling commits, i created a teeny git repo, did one commit,
then a "git commit --amend" to replace that earlier commit so, at this
point, i have a technically dangling commit, which i can see with:

$ git fsck --no-reflogs
Checking object directories: 100% (256/256), done.
Checking objects: 100% (4/4), done.
dangling commit ee059991a18f2ce363883113675de2aa0018ed0f
$

now i want to truly remove that dangling commit, but i see no
variation of "git gc" to do that. even if i run

$ git gc --prune=all

that commit is not removed.

  apparently, i *can* use a variation of "git reflog" and "git gc":

$ git reflog expire --expire-unreachable=now --all
$ git gc --prune=now

but is there no single invocation of "git gc" that will do it? will
all invocations of "git gc" still take into account the expiration
value associated with the reflog?

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================