Thread (6 messages) flat view 6 messages, 2 authors, 2016-06-15

removing files from history but not filesystem

From: Shantanu Pavgi <hidden>
Date: 2016-06-15 22:51:31

Hi,

How do I delete files from commit history, but still keep these files untracked on the filesystem? 

I tried 'git rm --cached' command using 'git filter-branch'; however it deleted file from the filesystem as well. 

{{{
$ git filter-branch --index-filter 'git rm --cached --ignore-unmatch */one.txt' HEAD
}}}

I am guessing since file is getting deleted from commit history (where it was created/modified), it won't be present on the filesystem as well. Am I following it correctly? Any further elaboration on this problem will be really helpful. 

Do I need to move concerned files to some other temporary location and rename them back to original filename? I have tried following commands with tree-filter, but it is failing as of now (second mv command needs to know correct filesystem path which was matched for */one.txt): 
{{{
$ git filter-branch -f --tree-filter \
'if [ -f */one.txt ]; then mv */one.txt */one.txt.keep; fi; rm -f */one.txt; if [ -f */one.txt.keep ]; then mv -f */one.txt.keep */one.txt; fi' \
HEAD
}}}
 
Any help?

--
Thanks,
Shantanu. 
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help