git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Removing some files from history

From
GKGennady Kushnir <genkush@rujel.net>
Date
Oct 17, 2008, 11:51 UTC
Message-ID
<96ed5eac0810170451y69fd864jb44ef62bca468498@mail.gmail.com>
In-Reply-To
<48F86E6A.7080102@fastmail.fm>
thank you for precise instructions.

however I did not completely understand the part about references and reflog what are these? git tags?

and another question: did I understand it right, that I can even make some changes to that file in history - not just simply delete one?

Gennady
2008/10/17 Michael J Gruber <michaeljgruber+gmane@fastmail.fm>:
Show 42 quoted lines
> Gennady Kushnir venit, vidit, dixit 17.10.2008 12:38:
>> Hello all
>> I'm not yet subscribed, but I wish I shall get reply anyway
>>
>> I'm going to make my repository public, but I have found that one of
>> my files contains some private data that I would not like to share.
>> Is it possible to remove that file from all commits in my local
>> repository history before publishing it?
>> Or it would be easier to start publishing with just my current state
>> (whith all private data cleaned up)?
>>
>> Thanks in advance.
>> Gennady
> Use
>
> git filter-branch --index-filter 'git rm --cached secret' -- --all
>
> or
>
> git filter-branch --tree-filter 'rm -f secret' -- --all
>
> where 'secret' is the name of the file to be removed.
>
> After that, make sure you clean up your repo before publishing:
> Clean out the original references (command on 1 line):
>
> git for-each-ref  --format='%(refname)' refs/original |while read ref;
> do git update-ref -d $ref;done
>
> Clean out the reflog:
>
> git reflog --expire=0 expire
>
> Remove the old objects and packs:
>
> git prune
> git repack -adf
>
> [Makes me feel this should be easier.]
>
> Michael
>
Previous: Michael J GruberNext: Jakub Narebski
Message 4 of 5 in “Removing some files from history”
  1. Gennady KushnirOct 17, 2008
  2. Jeff KingOct 17, 2008
  3. Michael J GruberOct 17, 2008
  4. Gennady KushnirOct 17, 2008
  5. Jakub NarebskiOct 17, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.