docs: add simple 'add' case to clarify setup.
[gitweb.git] / git-subtree.txt
index e7ce2d3654dcce65b2b983f3bc76bdd22ca939ec..cde5a7e73e830aab6bbb245354dcc5ff89ba9f17 100644 (file)
@@ -223,9 +223,33 @@ OPTIONS FOR split
        subproject's history to be part of your project anyway.
 
 
-EXAMPLES
---------
-Let's use the repository for the git source code as an example. 
+EXAMPLE 1
+---------
+Let's assume that you have a local repository that you would like
+to add an external vendor library to. In this case we will add the
+git-subtree repository as a subdirectory of your already existing
+git-extensions repository in ~/git-extensions/.
+
+First we need to fetch the remote objects
+       $ cd ~/git-extensions
+       $ git fetch git://github.com/apenwarr/git-subtree.git master
+
+'master' needs to be a valid remote ref and can be a different branch
+name
+
+Now we add the vendor library with
+       $ git subtree add --prefix=git-subtree --squash FETCH_HEAD
+
+You can omit the --squash flag, but doing so will increase the number
+of commits that are incldued in your local repository.
+
+We now have  ~/git-extensions/git-subtree directory with the git-subtree
+subdirectory containing code from the master branch of
+git://github.com/apenwarr/git-subtree.git
+
+EXAMPLE 2
+---------
+Let's use the repository for the git source code as an example.
 First, get your own copy of the git.git repository:
 
        $ git clone git://git.kernel.org/pub/scm/git/git.git test-git
@@ -258,7 +282,7 @@ And you can merge changes back in from the upstream project just
 as easily:
 
        $ git subtree pull --prefix=gitweb \
-               git@github.com:whatever/gitweb.git gitweb-latest:master
+               git@github.com:whatever/gitweb.git master
 
 Or, using '--squash', you can actually rewind to an earlier
 version of gitweb:
@@ -284,6 +308,23 @@ the standard gitweb:
 
        git log gitweb-latest..$(git subtree split --prefix=gitweb)
 
+EXAMPLE 3
+---------
+Suppose you have a source directory with many files and
+subdirectories, and you want to extract the lib directory to its own
+git project. Here's a short way to do it:
+
+First, make the new repository wherever you want:
+       <go to the new location>
+       git init --bare
+
+Back in your original directory:
+       git subtree split --prefix=lib --annotate="(split)" -b split
+
+Then push the new branch onto the new empty repository:
+        git push <new-repo> split:master
+
+
 
 AUTHOR
 ------