Re: removing files from history but not filesystem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Jun 29, 2011, at 1:08 AM, Christof Krüger wrote:

> Hi
> 
>> Thanks for the reply Chris. It worked for me. I am not following last
>> command "git reset <branch-name>" though. I have used SHA1 commit
>> object names in 'git reset' command, but I am not sure how <commit> is
>> using branch name here. Is  it because branch is a commit pointer in
>> the git history? 
> While being on the master branch, issuing "git reset temp" tells git to
> "let the master branch point to wherever the symbolic reference temp
> points now".  
> You did something very similar with git filter-branch already. There you
> specified HEAD~1, which is the same as telling git to dereference the
> symbolic ref "HEAD" and take its first parent. I don't know any place
> where git wouldn't accept symbolic references instead of raw sha1 sums.
> 
>> Also, how do I specify rev-list HEAD-1 so that 'git rm' will be run on
>> all commits excepts latest commit? Following didn't work for me, so I
>> guess I am not following syntax here.
>> {{{ $ git filter-branch
>> --index-filter 'git rm --cached --ignore-unmatch apple' HEAD~1
>> Which ref do you want to rewrite?
>> }}}
> git filter-branch expects a symbolic reference within the rev-list. It
> would be pointless to filter the commits without a symbolic reference
> being bent over to point to the rewritten branch once done.
> 
> What you can do is the following:
> 
> git filter-branch --index-filter 'test $GIT_COMMIT =
> 35644cb5fa34e033593f6f0d27c332443b6867d8 || git rm --cached
> --ignore-unmatch foo' HEAD
> 
> If "test $GIT_COMMIT = <sha1>" is true, the following git rm command
> won't be executed for that commit. 
> Choose the hash to be the one you want to skip (HEAD).
> 
> Another possible way would be to create a temporary branch to point at
> HEAD^, filter-branch it, then add a graft to stitch the remaining commit
> on top of it, then filter-branch HEAD and then remove the branch. But
> this is a bit advanced for the case where you just want to omit one
> commit.
> 
> Regards,
>  Chris
> 
> --


Thanks for explaining it in detail Chris. That's really helpful. 

--
Shantanu. 

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]