@matheusbsbs / matheus-bagliano / commits / 7f86ff0fe2
Fork 0

docs: Description, synopsys, options and examples changes.

Description: Made the difference from submodules and the subtree merge strategy clearer. Synopsys and options: Synchronize with 'git subtree -h' output. I hope, properly. Examples: Added example descriptions in captions. Small fixes. Signed-off-by: John Yani <vanuan@gmail.com>

John Yani committed Aug 12, 2010 at 19:54 UTC 7f86ff0fe292a5061757f3ceaffdd992c5feaa9f
1 file changed +69 -43
git-subtree.txt
+69 -43
@@ -3,50 +3,55 @@ git-subtree(1)
3
4 NAME
5 ----
6 -git-subtree - add, merge, and split subprojects stored in subtrees
6 +git-subtree - Merge subtrees together and split repository into subtrees
7
8
9 SYNOPSIS
10 --------
11 [verse]
12 -'git subtree' add --prefix=<prefix> <repository> <refspec...>
13 -'git subtree' pull --prefix=<prefix> <repository> <refspec...>
14 -'git subtree' push --prefix=<prefix> <repository> <refspec...>
15 -'git subtree' add --prefix=<prefix> <refspec>
16 -'git subtree' merge --prefix=<prefix> <refspec>
17 -'git subtree' split --prefix=<prefix> <refspec...>
18 -
12 +'git subtree' add -P <prefix>|--prefix=<prefix> <commit>
13 +'git subtree' pull -P <prefix>|--prefix=<prefix> <repository> <refspec...>
14 +'git subtree' push -P <prefix>|--prefix=<prefix> <repository> <refspec...>
15 +'git subtree' merge -P <prefix>|--prefix=<prefix> <commit>
16 +'git subtree' split -P <prefix>|--prefix=<prefix> [OPTIONS] [<commit>]
17 +
18
19 DESCRIPTION
20 -----------
22 -git subtree allows you to include a subproject in your
23 -own repository as a subdirectory, optionally including the
24 -subproject's entire history. For example, you could
25 -include the source code for a library as a subdirectory of your
26 -application.
27 -
28 -You can also extract the entire history of a subdirectory from
29 -your project and make it into a standalone project. For
30 -example, if a library you made for one application ends up being
31 -useful elsewhere, you can extract its entire history and publish
32 -that as its own git repository, without accidentally
33 -intermingling the history of your application project.
21 +Subtrees allow subprojects to be included within a subdirectory
22 +of the main project, optionally including the subproject's
23 +entire history.
24
35 -Most importantly, you can alternate back and forth between these
36 -two operations. If the standalone library gets updated, you can
25 +For example, you could include the source code for a library
26 +as a subdirectory of your application.
27 +
28 +Subtrees are not to be confused with submodules, which are meant for
29 +the same task. Unlike submodules, subtrees do not need any special
30 +constructions (like .gitmodule files or gitlinks) be present in
31 +your repository, and do not force end-users of your
32 +repository to do anything special or to understand how subtrees
33 +work. A subtree is just a subdirectory that can be
34 +committed to, branched, and merged along with your project in
35 +any way you want.
36 +
37 +They are neither not to be confused with using the subtree merge
38 +strategy. The main difference is that, besides merging
39 +of the other project as a subdirectory, you can also extract the
40 +entire history of a subdirectory from your project and make it
41 +into a standalone project. Unlike the subtree merge strategy
42 +you can alternate back and forth between these
43 +two operations. If the standalone library gets updated, you can
44 automatically merge the changes into your project; if you
45 update the library inside your project, you can "split" the
46 changes back out again and merge them back into the library
47 project.
48
42 -Unlike the 'git submodule' command, git subtree doesn't produce
43 -any special constructions (like .gitmodule files or gitlinks) in
44 -your repository, and doesn't require end-users of your
45 -repository to do anything special or to understand how subtrees
46 -work. A subtree is just another subdirectory and can be
47 -committed to, branched, and merged along with your project in
48 -any way you want.
49 +For example, if a library you made for one application ends up being
50 +useful elsewhere, you can extract its entire history and publish
51 +that as its own git repository, without accidentally
52 +intermingling the history of your application project.
53
54 +[TIP]
55 In order to keep your commit messages clean, we recommend that
56 people split their commits between the subtrees and the main
57 project as much as possible. That is, if you make a change that
@@ -128,20 +133,29 @@ OPTIONS
133 --debug::
134 Produce even more unnecessary output messages on stderr.
135
136 +-P <prefix>::
137 --prefix=<prefix>::
138 Specify the path in the repository to the subtree you
133 - want to manipulate. This option is currently mandatory
139 + want to manipulate. This option is mandatory
140 for all commands.
141
142 +-m <message>::
143 +--message=<message>::
144 + This option is only valid for add, merge and pull (unsure).
145 + Specify <message> as the commit message for the merge commit.
146
137 -OPTIONS FOR add, merge, AND pull
138 ---------------------------------
147 +
148 +OPTIONS FOR add, merge, push, pull
149 +----------------------------------
150 --squash::
151 + This option is only valid for add, merge, push and pull
152 + commands.
153 +
154 Instead of merging the entire history from the subtree
155 project, produce only a single commit that contains all
156 the differences you want to merge, and then merge that
157 new commit into your project.
144 -
158 +
159 Using this option helps to reduce log clutter. People
160 rarely want to see every change that happened between
161 v1.0 and v1.1 of the library they're using, since none of the
@@ -169,6 +183,8 @@ OPTIONS FOR add, merge, AND pull
183 OPTIONS FOR split
184 -----------------
185 --annotate=<annotation>::
186 + This option is only valid for the split command.
187 +
188 When generating synthetic history, add <annotation> as a
189 prefix to each commit message. Since we're creating new
190 commits with the same commit message, but possibly
@@ -184,12 +200,16 @@ OPTIONS FOR split
200
201 -b <branch>::
202 --branch=<branch>::
203 + This option is only valid for the split command.
204 +
205 After generating the synthetic history, create a new
206 branch called <branch> that contains the new history.
207 This is suitable for immediate pushing upstream.
208 <branch> must not already exist.
209
210 --ignore-joins::
211 + This option is only valid for the split command.
212 +
213 If you use '--rejoin', git subtree attempts to optimize
214 its history reconstruction to generate only the new
215 commits since the last '--rejoin'. '--ignore-join'
@@ -198,6 +218,8 @@ OPTIONS FOR split
218 long time.
219
220 --onto=<onto>::
221 + This option is only valid for the split command.
222 +
223 If your subtree was originally imported using something
224 other than git subtree, its history may not match what
225 git subtree is expecting. In that case, you can specify
@@ -210,6 +232,8 @@ OPTIONS FOR split
232 this option.
233
234 --rejoin::
235 + This option is only valid for the split command.
236 +
237 After splitting, merge the newly created synthetic
238 history back into your main project. That way, future
239 splits can search only the part of history that has
@@ -231,8 +255,8 @@ OPTIONS FOR split
255 subproject's history to be part of your project anyway.
256
257
234 -EXAMPLE 1
235 ----------
258 +EXAMPLE 1. Add command
259 +----------------------
260 Let's assume that you have a local repository that you would like
261 to add an external vendor library to. In this case we will add the
262 git-subtree repository as a subdirectory of your already existing
@@ -251,8 +275,8 @@ We now have a ~/git-extensions/git-subtree directory containing code
275 from the master branch of git://github.com/apenwarr/git-subtree.git
276 in our git-extensions repository.
277
254 -EXAMPLE 2
255 ----------
278 +EXAMPLE 2. Extract a subtree using commit, merge and pull
279 +---------------------------------------------------------
280 Let's use the repository for the git source code as an example.
281 First, get your own copy of the git.git repository:
282
@@ -312,22 +336,24 @@ the standard gitweb:
336
337 git log gitweb-latest..$(git subtree split --prefix=gitweb)
338
315 -EXAMPLE 3
316 ----------
339 +EXAMPLE 3. Extract a subtree using branch
340 +-----------------------------------------
341 Suppose you have a source directory with many files and
342 subdirectories, and you want to extract the lib directory to its own
343 git project. Here's a short way to do it:
344
345 First, make the new repository wherever you want:
322 - <go to the new location>
323 - git init --bare
346 +
347 + $ <go to the new location>
348 + $ git init --bare
349
350 Back in your original directory:
326 - git subtree split --prefix=lib --annotate="(split)" -b split
351 +
352 + $ git subtree split --prefix=lib --annotate="(split)" -b split
353
354 Then push the new branch onto the new empty repository:
329 - git push <new-repo> split:master
355
356 + $ git push <new-repo> split:master
357
358
359 AUTHOR