git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael O'Cleirigh <michael.ocleirigh@rivulet.ca>
To: git@vger.kernel.org
Cc: Michael O'Cleirigh <michael.ocleirigh@rivulet.ca>
Subject: [PATCH 1/1] Documentation/git-filter-branch: add --index-filter example
Date: Wed, 27 Apr 2011 14:08:04 -0400	[thread overview]
Message-ID: <1303927684-6513-2-git-send-email-michael.ocleirigh@rivulet.ca> (raw)
In-Reply-To: <1303927684-6513-1-git-send-email-michael.ocleirigh@rivulet.ca>

Added an example using git ls-tree on the $GIT_COMMIT and then filtering
what should remain in the history using egrep.

This allows multiple paths accross history to be retained when filtering a branch.
---
 Documentation/git-filter-branch.txt |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/Documentation/git-filter-branch.txt b/Documentation/git-filter-branch.txt
index 9dc1f2a..e80bc01 100644
--- a/Documentation/git-filter-branch.txt
+++ b/Documentation/git-filter-branch.txt
@@ -248,6 +248,19 @@ To set a commit (which typically is at the tip of another
 history) to be the parent of the current initial commit, in
 order to paste the other history behind the current history:
 
+-----------------------------------------------------------------------------------------------------------------------------------
+git filter-branch --prune-empty --index-filter 'git ls-tree $GIT_COMMIT | egrep \
+"(top-dir-A|top-dir-B|consolidated-dir-C)" | git mktree | xargs git read-tree -i -m'
+-----------------------------------------------------------------------------------------------------------------------------------
+
+The --subdirectory-filter works great when all commits of interest have
+that path but sometimes you have a history that contains an irregular 
+structure. i.e. that was reorganized at some point and you would like to 
+keep the prior history.
+
+For each commit the top-dir-A, top-dir-B and consolidated-dir-C paths (if they exist)
+are kept (and everything else discarded). 
+
 -------------------------------------------------------------------
 git filter-branch --parent-filter 'sed "s/^\$/-p <graft-id>/"' HEAD
 -------------------------------------------------------------------
-- 
1.7.2.3

  reply	other threads:[~2011-04-27 18:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-27 18:08 [PATCH 0/1] Add new --index-filter example to git-filter-branch.txt Michael O'Cleirigh
2011-04-27 18:08 ` Michael O'Cleirigh [this message]
2011-04-27 20:32   ` [PATCH 1/1] Documentation/git-filter-branch: add --index-filter example Johannes Sixt
2011-04-27 19:24 ` [PATCH 0/1] Add new --index-filter example to git-filter-branch.txt Sverre Rabbelier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1303927684-6513-2-git-send-email-michael.ocleirigh@rivulet.ca \
    --to=michael.ocleirigh@rivulet.ca \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).