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

Re: removing files from history but not filesystem

From
SPShantanu Pavgi <pavgi@uab.edu>
Date
Jun 29, 2011, 04:10 UTC
Message-ID
<D56E9579-BD93-42AC-BA45-E0DC20F4BB48@uab.edu>
In-Reply-To
<218bf1d3b2bf197a5f56d542c6a91960.squirrel@mail.localhost.li>
On Jun 28, 2011, at 2:04 AM, Christof Krüger wrote:
Show 18 quoted lines
> Hi,
> 
>> $ git filter-branch --index-filter 'git rm --cached --ignore-unmatch
>> */one.txt' HEAD
> 
> The following should work:
> 
> git branch temp
> git filter-branch --index-filter 'git rm --cached --ignore-unmatch foo' temp
> git reset temp
> 
> This creates branch "temp" pointing to the same commit as "master".
> Then you filter-branch the "temp" branch. This leaves file "foo" in your
> working directory intact, as your current branch is actually "master". The
> third step resets your current "branch" to the commit pointed by the
> rewritten branch "temp". The default for git reset is --mixed which
> according to the man page leaves the working tree alone.
> 
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? 

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? }}}

Any help? 

-- Thanks, Shantanu.

Previous: Christof KrügerNext: Christof Krüger
Message 3 of 6 in “removing files from history but not filesystem”
  1. Shantanu PavgiJun 28, 2011
  2. Christof KrügerJun 28, 2011
  3. Shantanu PavgiJun 29, 2011
  4. Christof KrügerJun 29, 2011
  5. Christof KrügerJun 29, 2011
  6. Shantanu PavgiJun 29, 2011

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.