sites
sites

Reputation: 21775

Remove git commit that is not in history

I had something like this:

A - B - C

I amended C and I had:

A - B - D

And C in floating somewhere else, how can I delete C from local and remote repository?

There are no pointers to C. But I can read its hash in Github. How can I force the garbage collection and push this to remote?

Upvotes: 0

Views: 132

Answers (2)

sites
sites

Reputation: 21775

From github support

Be warned that force-pushing does not erase commits on the remote repo, it simply introduces new ones and moves the branch pointer to point to them. If you are worried about users accessing the bad commits directly via SHA1, you will have to delete the repo and recreate it.

Thanks.

Upvotes: 1

dty
dty

Reputation: 18998

You'll need to be a bit more specific about what you really did, what refs (heads, "pointers") point to which commits, etc. before you can get a specific answer.

In general, if no refs point to your old commit, C, then it will be garbage collected in time.

If you have refs pointing to C and you want C to disappear, you need to remove those refs. Of course, you need to understand the potential effects of doing that - i.e. what other commits might disappear.

Upvotes: 0

Related Questions