On Mon, 11 Mar 2013 22:05:47 +0800
lei yang <yanglei.f...@gmail.com> wrote:

> Branch A content is
> lyang001@lyang001-OptiPlex-9010:~/meta-networking$ ls
>  README  recipes-connectivity  recipes-daemons  recipes-filter
> recipes-protocols  recipes-support  sub.sh  xx.sh
> I want to create a new branch named "support" and make it contain
> "recipes-support" (recipes-support is a directory and  contains lots
> of file )
> eg:
> the "support" branch should be like below
> lyang001@lyang001-OptiPlex-9010:~/meta-networking$ ls
> recipes-support

Depends on what you really intend to get.  I will list possible
scenarios which come to mind in order from the simplest to the most

If the new prospective branch should *start* with the current contents
of "recipes-support" -- that is, this should be the first commit on that
branch, then you should create an orphaned branch (I think you were the
one recently asking about creating such a branch on this list) out of
the current state, delete everything but the "recipes-support"
directory from the index, then commit.

If the new branch should contain all the history of "recipes-support",
but you're fine with the fact the past commits will contain directories
other than "recipes-support", just fork another branch off A, delete
all unwanted directories and commit.

If that new prospective branch should contain all the history of
changes to files under "recipes-support" as is currently recorded in
the branch "A" but at the same those historic changes must not contain
any traces of other directories and files currently present in the
commits of A, then the answer to your problem is git-subtree [1]
(available as a "contrib" script within Git itself since some time [2])
and its "split" command -- it's able to extract the specified directory
to its own branch and synthesize all the historic commits touching the
contents of that directory.

1. https://github.com/apenwarr/git-subtree
2. https://github.com/git/git/tree/master/contrib/subtree

You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to