What have you found for these years?


git filter-branch (2)

Say you want to extract a feature in a project called A to a
new project called B, and the feature is in file0.txt and file1.txt,
and reserved all commits logs. Then clone the project first:

> git clone A/.git B

Then invoke this crazy command:

> git filter-branch --prune-empty --index-filter \
"git ls-files | egrep --invert-match '(file0.txt)|(file1.txt)' |
xargs git rm --cached --ignore-unmatch"

But I don't know how to remove empty merge commits...
The docs say --prune-empty didn't apply to merge commits:
Some kind of filters will generate empty commits, that left the
tree untouched. This switch allow git-filter-branch to ignore such
commits. Though, this switch only applies for commits that have one
and only one parent, it will hence keep merges points. Also, this
option is not compatible with the use of --commit-filter. Though
you just need to use the function git_commit_non_empty_tree "$@"
instead of the git commit-tree "$@" idiom in your commit filter to
make that happen.
Google says nothing as well. Anyone?

0 retries:

Post a Comment

Note: Only a member of this blog may post a comment.

All texts are licensed under CC Attribution 3.0