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?
Thanks very much,
Whit
From: Thomas Jarosch <hidden> Date: 2016-06-15 22:45:47
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
On Thu, Dec 18, 2008 at 14:51, Whit Armstrong [off-list ref] 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?
I think "git filter-branch" is what you need. Have it filter out
changes to files but foo.c, and then remove all empty commits.
--
Cheers,
Sverre Rabbelier
thanks, I will give this a try.
On Thu, Dec 18, 2008 at 9:04 AM, Thomas Jarosch
[off-list ref] wrote:
On Thursday, 18. December 2008 14:51:12 Whit Armstrong wrote:
quoted
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
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 \
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
[off-list ref] wrote:
thanks, I will give this a try.
On Thu, Dec 18, 2008 at 9:04 AM, Thomas Jarosch
[off-list ref] wrote:
quoted
On Thursday, 18. December 2008 14:51:12 Whit Armstrong wrote:
quoted
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
From: Thomas Jarosch <hidden> Date: 2016-06-15 22:45:48
On Thursday, 18. December 2008 20:51:38 Whit Armstrong wrote:
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?
Hmm, I guess you have an empty commit in your repository like I did.
This is currently a corner case in update-index, which does not create empty
index files. I posted a patch a few days ago and Junio posted an updated
version of that. I could send you my version for git 1.6.0.5 if you need it.
Is there a good site that documents this procedure?
A good start is the git-filter-branch man page and the mailinglist archive.
Thomas
thanks, Thomas. I could definitely pull from your tree. seems like
the path of least resistance to get my repo split.
Cheers,
Whit
On Fri, Dec 19, 2008 at 4:44 AM, Thomas Jarosch
[off-list ref] wrote:
On Thursday, 18. December 2008 20:51:38 Whit Armstrong wrote:
quoted
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?
Hmm, I guess you have an empty commit in your repository like I did.
This is currently a corner case in update-index, which does not create empty
index files. I posted a patch a few days ago and Junio posted an updated
version of that. I could send you my version for git 1.6.0.5 if you need it.
quoted
Is there a good site that documents this procedure?
A good start is the git-filter-branch man page and the mailinglist archive.
Thomas
From: Thomas Jarosch <hidden> Date: 2016-06-15 22:45:48
On Friday, 19. December 2008 14:08:23 Whit Armstrong wrote:
thanks, Thomas. I could definitely pull from your tree. seems like
the path of least resistance to get my repo split.
Here's the patch I use for git 1.6.0.5. According to Junio
it has the small drawback of always writing out the index,
even if there are no changes.
If you need an updated patch against HEAD, look for Junio's reply
to my patch in the list archive.
Enjoy,
Thomas
Signed-off-by: Thomas Jarosch <redacted>
@@ -307,6 +309,8 @@ static void read_index_info(int line_terunsignedlongul;intstage;+found_something=1;+/* This reads lines formatted in one of three formats:**(1)modeSPsha1TABpath
@@ -382,6 +386,11 @@ static void read_index_info(int line_terbad_line:die("malformed index info %s",buf.buf);}++/* Force creation of empty index - needed by git filter-branch */+if(!found_something)+active_cache_changed=1;+strbuf_release(&buf);strbuf_release(&uq);}