{"thread":{"id":"10088","subject":"Obliterating a commit","startedAt":"2007-09-30T11:32:36Z","lastAt":"2007-09-30T14:13:17Z","messageCount":3,"participants":["Wincent Colaiuta","Matthias Kestenholz"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"54404","messageId":"D2BD14BD-44F2-4D01-AAEE-6CBC2A2DE85B@wincent.com","threadId":"10088","inReplyTo":null,"subject":"Obliterating a commit","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2007-09-30T11:32:36Z","receivedAt":"2007-09-30T11:32:36Z","isPatch":false,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"A couple of days ago I mistakenly checked in a file that had some  \nconfidential information in it. I immediately realized and amended my  \ncommit, and this is a local repository whose contents won't be  \nvisible until I push them out.\n\nSo how do I *really* get rid of the that commit before publishing? I  \ncouldn't find any porcelain or plumbing to do this. Do I have to  \nmanually destroy it? ie. wind back the HEAD, manually remove the  \ncommit object, the corresponding tree object, the corresponding file  \nblobs, and probably manually remove the entry from the reflog as well?\n\nIs there a \"shortcut\" wherein I can somehow mark this commit and its  \nrelated tree and file blobs as unreachable, and then use git-prune to  \nerradicate them?\n\nCheers,\nWincent\n"},{"id":"54405","messageId":"1f6632e50709300515h57f4b4ffh9a18fef29b134f13@mail.gmail.com","threadId":"10088","inReplyTo":"D2BD14BD-44F2-4D01-AAEE-6CBC2A2DE85B@wincent.com","subject":"Re: Obliterating a commit","fromName":"Matthias Kestenholz","fromEmail":"lists@spinlock.ch","sentAt":"2007-09-30T12:15:27Z","receivedAt":"2007-09-30T12:15:27Z","isPatch":false,"sender":{"key":"lists@spinlock.ch","avatar":null},"body":"Hello,\n\n2007/9/30, Wincent Colaiuta <win@wincent.com>:\n> A couple of days ago I mistakenly checked in a file that had some\n> confidential information in it. I immediately realized and amended my\n> commit, and this is a local repository whose contents won't be\n> visible until I push them out.\n>\n> So how do I *really* get rid of the that commit before publishing? I\n> couldn't find any porcelain or plumbing to do this. Do I have to\n> manually destroy it? ie. wind back the HEAD, manually remove the\n> commit object, the corresponding tree object, the corresponding file\n> blobs, and probably manually remove the entry from the reflog as well?\n>\n\nIf you use ssh to push your changes (that is, you are not copying\nor rsyncing packfiles), only commits, trees and blobs, which are reachable\nthrough the DAG will be published. Commits and Blobs which are only\nreachable through your reflog are not published, since the reflog only applies\nto your local repository.\n\nThe simplest thing you could do is remove the reflog for HEAD and\nrefs/heads/master respectively your current branch and run 'git prune'\nafterwards (if you have not repacked\nalready, otherwise you'd need to run 'git repack -a -d' or 'git gc' to get\nrid of blobs inside your packfile.\n\n> Is there a \"shortcut\" wherein I can somehow mark this commit and its\n> related tree and file blobs as unreachable, and then use git-prune to\n> erradicate them?\n>\n\nYou don't need to mark anything -- it's sufficient that the blob with the\nconfidential information is only reachable through the reflog (which you\nneed to remove, obviously, if you want to get rid of the blob locally too)\n\n\nCheers,\nMatthias\n"},{"id":"54412","messageId":"57945943-2355-447D-9474-89834BADB312@wincent.com","threadId":"10088","inReplyTo":"1f6632e50709300515h57f4b4ffh9a18fef29b134f13@mail.gmail.com","subject":"Re: Obliterating a commit","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2007-09-30T14:13:17Z","receivedAt":"2007-09-30T14:13:17Z","isPatch":false,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"El 30/9/2007, a las 14:15, Matthias Kestenholz escribió:\n\n> If you use ssh to push your changes (that is, you are not copying\n> or rsyncing packfiles), only commits, trees and blobs, which are  \n> reachable\n> through the DAG will be published. Commits and Blobs which are only\n> reachable through your reflog are not published, since the reflog  \n> only applies\n> to your local repository.\n\nAh, this is good to know. Yes, I do principally publish by pushing to  \na central repo, but I wanted to really destroy the objects just in  \ncase in the future I or somebody else ever clones my local repo.\n\n> The simplest thing you could do is remove the reflog for HEAD and\n> refs/heads/master respectively your current branch and run 'git prune'\n> afterwards (if you have not repacked\n> already, otherwise you'd need to run 'git repack -a -d' or 'git gc'  \n> to get\n> rid of blobs inside your packfile.\n\nThanks very much, Matthias. Blowing away those reflogs and running  \ngit-prune worked and it's doesn't require too much fiddling.\n\nCheers,\nWincent\n"}]}