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

Re: is it possible filter the revision history of a single file into another repository?

From
Whit Armstrong <armstrong.whit@gmail.com>
Date
Dec 18, 2008, 19:51 UTC
Message-ID
<8ec76080812181151y4a5a6f5cna57785c935032e77@mail.gmail.com>
In-Reply-To
<8ec76080812180619k78a28e30t591b514148202869@mail.gmail.com>

Sorry, seem to be getting this error: `/home/whit/dvl/risk.metrics.utils/RiskMetrics/.git-rewrite/t/../index.new': No such file or directory

do I need to set up the index file first?
Is there a good site that documents this procedure?

[whit@linuxsvr RiskMetrics]$ git filter-branch --tag-name-filter cat --index-filter \

>    'git ls-files -s |grep -P "riskmetrics.rb" \
>    |GIT_INDEX_FILE=$GIT_INDEX_FILE.new git update-index --index-info &&
>    mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' -- --all
Rewrite 8f1a0eaae033d109f4a3a4b410bd8e04dd9997db (1/481)mv: cannot
stat `/home/whit/dvl/risk.metrics.utils/RiskMetrics/.git-rewrite/t/../index.new':
No such file or directory
index filter failed: git ls-files -s |grep -P "riskmetrics.rb" \
   |GIT_INDEX_FILE=$GIT_INDEX_FILE.new git update-index --index-info &&
   mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE
[whit@linuxsvr RiskMetrics]$

On Thu, Dec 18, 2008 at 9:19 AM, Whit Armstrong <armstrong.whit@gmail.com> wrote:

Show 39 quoted lines
> thanks, I will give this a try.
>
> On Thu, Dec 18, 2008 at 9:04 AM, Thomas Jarosch
> <thomas.jarosch@intra2net.com> wrote:
>> On Thursday, 18. December 2008 14:51:12 Whit Armstrong wrote:
>>> For instance, if my repository contains foo.c, and 100 other files.
>>>
>>> I would like to create a new and separate repository containing only
>>> the revision history of foo.c.
>>>
>>> Would someone mind pointing me at some documentation for this
>>> procedure if it exists?
>>
>> This worked for me:
>>
>> git filter-branch --tag-name-filter cat --index-filter \
>>    'git ls-files -s |grep -P "\t(DIR1|DIR2)" \
>>    |GIT_INDEX_FILE=$GIT_INDEX_FILE.new git update-index --index-info &&
>>    mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' -- --all
>>
>> Run "git ls-files -s" to see the output format.
>> Replace the "DIR1|DIR2" with "foo.c".
>>
>> Later on you might want to remove empty commits from the history:
>> git filter-branch --tag-name-filter cat --commit-filter 'if [ z$1 = z`git rev-parse $3^{tree}` ]; then skip_commit "$@"; else git commit-tree "$@"; fi' "$@" -- --all
>>
>> If you want to run two filter-branch commands in a row
>> or you want to free up the space in .git afterwards:
>>
>> - git for-each-ref --format='%(refname)' refs/original | xargs -i git update-ref -d {}
>> - git reflog expire --expire=0 --all
>> - git repack -a -d
>> - git prune
>>
>> Cheers,
>> Thomas
>>
>>
>
Previous: Whit ArmstrongNext: Thomas Jarosch
Message 4 of 8 in “is it possible filter the revision history of a single file into another repository?”
  1. Whit ArmstrongDec 18, 2008
  2. Thomas JaroschDec 18, 2008
  3. Whit ArmstrongDec 18, 2008
  4. Whit ArmstrongDec 18, 2008
  5. Thomas JaroschDec 19, 2008
  6. Whit ArmstrongDec 19, 2008
  7. Thomas JaroschDec 19, 2008
  8. Sverre RabbelierDec 18, 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.