* Removing some files from history
@ 2008-10-17 10:38 Gennady Kushnir
2008-10-17 10:42 ` Jeff King
2008-10-17 10:52 ` Michael J Gruber
0 siblings, 2 replies; 5+ messages in thread
From: Gennady Kushnir @ 2008-10-17 10:38 UTC (permalink / raw)
To: git
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Removing some files from history
2008-10-17 10:38 Removing some files from history Gennady Kushnir
@ 2008-10-17 10:42 ` Jeff King
2008-10-17 10:52 ` Michael J Gruber
1 sibling, 0 replies; 5+ messages in thread
From: Jeff King @ 2008-10-17 10:42 UTC (permalink / raw)
To: Gennady Kushnir; +Cc: git
On Fri, Oct 17, 2008 at 02:38:54PM +0400, Gennady Kushnir wrote:
> 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?
Yes, see "git help filter-branch". The first example given does exactly
what you are asking for.
-Peff
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Removing some files from history
2008-10-17 10:38 Removing some files from history Gennady Kushnir
2008-10-17 10:42 ` Jeff King
@ 2008-10-17 10:52 ` Michael J Gruber
2008-10-17 11:51 ` Gennady Kushnir
1 sibling, 1 reply; 5+ messages in thread
From: Michael J Gruber @ 2008-10-17 10:52 UTC (permalink / raw)
To: Gennady Kushnir; +Cc: git
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Removing some files from history
2008-10-17 10:52 ` Michael J Gruber
@ 2008-10-17 11:51 ` Gennady Kushnir
2008-10-17 12:20 ` Jakub Narebski
0 siblings, 1 reply; 5+ messages in thread
From: Gennady Kushnir @ 2008-10-17 11:51 UTC (permalink / raw)
To: Michael J Gruber; +Cc: git
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>:
> 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
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Removing some files from history
2008-10-17 11:51 ` Gennady Kushnir
@ 2008-10-17 12:20 ` Jakub Narebski
0 siblings, 0 replies; 5+ messages in thread
From: Jakub Narebski @ 2008-10-17 12:20 UTC (permalink / raw)
To: Gennady Kushnir; +Cc: Michael J Gruber, git
Please do not toppost, and quote only fragments you are replying to.
"Gennady Kushnir" <genkush@rujel.net> writes:
> thank you for precise instructions.
>
> however I did not completely understand the part about references
> and reflog what are these? git tags?
git-filter-branch saves old version under refs/original/* namespace.
You have to remove them after making sure that your rewritten history
is correct.
Additionally git keeps log where branch (tip/head of branch) was in
your repository; this is kind of generalization of ORIG_HEAD, and
allows to recover from such mistakes as wrong "git reset --hard".
Reflog entries from your original history also would pin commits, so
you have to expire reflog.
And finally the commits you have are there in repository, so you have
to "prune" repository to get rid of them. Reflog entries and
refs/original/* pin those commits, so you have to remove them prior to
pruning. Pruning simply removes objects which are unreferenced.
> 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?
Yes, see man git-filter-branch.
--
Jakub Narebski
Poland
ShadeHawk on #git
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-10-17 12:21 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-17 10:38 Removing some files from history Gennady Kushnir
2008-10-17 10:42 ` Jeff King
2008-10-17 10:52 ` Michael J Gruber
2008-10-17 11:51 ` Gennady Kushnir
2008-10-17 12:20 ` Jakub Narebski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).