# Obliterating a commit

3 messages from 2007-09-30 to 2007-09-30. Participants: Wincent Colaiuta, Matthias Kestenholz.
Thread: https://gitlist.dev/t/10088

## Wincent Colaiuta, 2007-09-30 11:32

Subject: Obliterating a commit
Message-ID: <D2BD14BD-44F2-4D01-AAEE-6CBC2A2DE85B@wincent.com>
URL: https://gitlist.dev/e/D2BD14BD-44F2-4D01-AAEE-6CBC2A2DE85B%40wincent.com

```
A couple of days ago I mistakenly checked in a file that had some  
confidential information in it. I immediately realized and amended my  
commit, and this is a local repository whose contents won't be  
visible until I push them out.

So how do I *really* get rid of the that commit before publishing? I  
couldn't find any porcelain or plumbing to do this. Do I have to  
manually destroy it? ie. wind back the HEAD, manually remove the  
commit object, the corresponding tree object, the corresponding file  
blobs, and probably manually remove the entry from the reflog as well?

Is there a "shortcut" wherein I can somehow mark this commit and its  
related tree and file blobs as unreachable, and then use git-prune to  
erradicate them?

Cheers,
Wincent

```

## Matthias Kestenholz, 2007-09-30 12:15

Subject: Re: Obliterating a commit
Message-ID: <1f6632e50709300515h57f4b4ffh9a18fef29b134f13@mail.gmail.com>
URL: https://gitlist.dev/e/1f6632e50709300515h57f4b4ffh9a18fef29b134f13%40mail.gmail.com
In-Reply-To: <D2BD14BD-44F2-4D01-AAEE-6CBC2A2DE85B@wincent.com>

```
Hello,

2007/9/30, Wincent Colaiuta <win@wincent.com>:
> A couple of days ago I mistakenly checked in a file that had some
> confidential information in it. I immediately realized and amended my
> commit, and this is a local repository whose contents won't be
> visible until I push them out.
>
> So how do I *really* get rid of the that commit before publishing? I
> couldn't find any porcelain or plumbing to do this. Do I have to
> manually destroy it? ie. wind back the HEAD, manually remove the
> commit object, the corresponding tree object, the corresponding file
> blobs, and probably manually remove the entry from the reflog as well?
>

If you use ssh to push your changes (that is, you are not copying
or rsyncing packfiles), only commits, trees and blobs, which are reachable
through the DAG will be published. Commits and Blobs which are only
reachable through your reflog are not published, since the reflog only applies
to your local repository.

The simplest thing you could do is remove the reflog for HEAD and
refs/heads/master respectively your current branch and run 'git prune'
afterwards (if you have not repacked
already, otherwise you'd need to run 'git repack -a -d' or 'git gc' to get
rid of blobs inside your packfile.

> Is there a "shortcut" wherein I can somehow mark this commit and its
> related tree and file blobs as unreachable, and then use git-prune to
> erradicate them?
>

You don't need to mark anything -- it's sufficient that the blob with the
confidential information is only reachable through the reflog (which you
need to remove, obviously, if you want to get rid of the blob locally too)


Cheers,
Matthias

```

## Wincent Colaiuta, 2007-09-30 14:13

Subject: Re: Obliterating a commit
Message-ID: <57945943-2355-447D-9474-89834BADB312@wincent.com>
URL: https://gitlist.dev/e/57945943-2355-447D-9474-89834BADB312%40wincent.com
In-Reply-To: <1f6632e50709300515h57f4b4ffh9a18fef29b134f13@mail.gmail.com>

```
El 30/9/2007, a las 14:15, Matthias Kestenholz escribió:

> If you use ssh to push your changes (that is, you are not copying
> or rsyncing packfiles), only commits, trees and blobs, which are  
> reachable
> through the DAG will be published. Commits and Blobs which are only
> reachable through your reflog are not published, since the reflog  
> only applies
> to your local repository.

Ah, this is good to know. Yes, I do principally publish by pushing to  
a central repo, but I wanted to really destroy the objects just in  
case in the future I or somebody else ever clones my local repo.

> The simplest thing you could do is remove the reflog for HEAD and
> refs/heads/master respectively your current branch and run 'git prune'
> afterwards (if you have not repacked
> already, otherwise you'd need to run 'git repack -a -d' or 'git gc'  
> to get
> rid of blobs inside your packfile.

Thanks very much, Matthias. Blowing away those reflogs and running  
git-prune worked and it's doesn't require too much fiddling.

Cheers,
Wincent

```
