Merge branch 'ls/subtree'
"git subtree" updates. * ls/subtree: (30 commits) subtree: be stricter about validating flags subtree: push: allow specifying a local rev other than HEAD subtree: allow 'split' flags to be passed to 'push' subtree: allow --squash to be used with --rejoin subtree: give the docs a once-over subtree: have $indent actually affect indentation subtree: don't let debug and progress output clash subtree: add comments and sanity checks subtree: remove duplicate check subtree: parse revs in individual cmd_ functions subtree: use "^{commit}" instead of "^0" subtree: don't fuss with PATH subtree: use "$*" instead of "$@" as appropriate subtree: use more explicit variable names for cmdline args subtree: use git-sh-setup's `say` subtree: use `git merge-base --is-ancestor` subtree: drop support for git < 1.7 subtree: more consistent error propagation subtree: don't have loose code outside of a function subtree: t7900: add porcelain tests for 'pull' and 'push' ...maint
commit
44ccb7629a
|
@ -163,6 +163,7 @@
|
||||||
/git-stripspace
|
/git-stripspace
|
||||||
/git-submodule
|
/git-submodule
|
||||||
/git-submodule--helper
|
/git-submodule--helper
|
||||||
|
/git-subtree
|
||||||
/git-svn
|
/git-svn
|
||||||
/git-switch
|
/git-switch
|
||||||
/git-symbolic-ref
|
/git-symbolic-ref
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -9,13 +9,14 @@ git-subtree - Merge subtrees together and split repository into subtrees
|
||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
--------
|
--------
|
||||||
[verse]
|
[verse]
|
||||||
'git subtree' add -P <prefix> <commit>
|
'git subtree' [<options>] -P <prefix> add <local-commit>
|
||||||
'git subtree' add -P <prefix> <repository> <ref>
|
'git subtree' [<options>] -P <prefix> add <repository> <remote-ref>
|
||||||
'git subtree' pull -P <prefix> <repository> <ref>
|
'git subtree' [<options>] -P <prefix> merge <local-commit>
|
||||||
'git subtree' push -P <prefix> <repository> <ref>
|
'git subtree' [<options>] -P <prefix> split [<local-commit>]
|
||||||
'git subtree' merge -P <prefix> <commit>
|
|
||||||
'git subtree' split -P <prefix> [OPTIONS] [<commit>]
|
|
||||||
|
|
||||||
|
[verse]
|
||||||
|
'git subtree' [<options>] -P <prefix> pull <repository> <remote-ref>
|
||||||
|
'git subtree' [<options>] -P <prefix> push <repository> <refspec>
|
||||||
|
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
-----------
|
-----------
|
||||||
|
@ -28,7 +29,7 @@ as a subdirectory of your application.
|
||||||
|
|
||||||
Subtrees are not to be confused with submodules, which are meant for
|
Subtrees are not to be confused with submodules, which are meant for
|
||||||
the same task. Unlike submodules, subtrees do not need any special
|
the same task. Unlike submodules, subtrees do not need any special
|
||||||
constructions (like .gitmodules files or gitlinks) be present in
|
constructions (like '.gitmodules' files or gitlinks) be present in
|
||||||
your repository, and do not force end-users of your
|
your repository, and do not force end-users of your
|
||||||
repository to do anything special or to understand how subtrees
|
repository to do anything special or to understand how subtrees
|
||||||
work. A subtree is just a subdirectory that can be
|
work. A subtree is just a subdirectory that can be
|
||||||
|
@ -59,70 +60,71 @@ project as much as possible. That is, if you make a change that
|
||||||
affects both the library and the main application, commit it in
|
affects both the library and the main application, commit it in
|
||||||
two pieces. That way, when you split the library commits out
|
two pieces. That way, when you split the library commits out
|
||||||
later, their descriptions will still make sense. But if this
|
later, their descriptions will still make sense. But if this
|
||||||
isn't important to you, it's not *necessary*. git subtree will
|
isn't important to you, it's not *necessary*. 'git subtree' will
|
||||||
simply leave out the non-library-related parts of the commit
|
simply leave out the non-library-related parts of the commit
|
||||||
when it splits it out into the subproject later.
|
when it splits it out into the subproject later.
|
||||||
|
|
||||||
|
|
||||||
COMMANDS
|
COMMANDS
|
||||||
--------
|
--------
|
||||||
add::
|
add <local-commit>::
|
||||||
|
add <repository> <remote-ref>::
|
||||||
Create the <prefix> subtree by importing its contents
|
Create the <prefix> subtree by importing its contents
|
||||||
from the given <commit> or <repository> and remote <ref>.
|
from the given <local-commit> or <repository> and <remote-ref>.
|
||||||
A new commit is created automatically, joining the imported
|
A new commit is created automatically, joining the imported
|
||||||
project's history with your own. With '--squash', imports
|
project's history with your own. With '--squash', import
|
||||||
only a single commit from the subproject, rather than its
|
only a single commit from the subproject, rather than its
|
||||||
entire history.
|
entire history.
|
||||||
|
|
||||||
merge::
|
merge <local-commit>::
|
||||||
Merge recent changes up to <commit> into the <prefix>
|
Merge recent changes up to <local-commit> into the <prefix>
|
||||||
subtree. As with normal 'git merge', this doesn't
|
subtree. As with normal 'git merge', this doesn't
|
||||||
remove your own local changes; it just merges those
|
remove your own local changes; it just merges those
|
||||||
changes into the latest <commit>. With '--squash',
|
changes into the latest <local-commit>. With '--squash',
|
||||||
creates only one commit that contains all the changes,
|
create only one commit that contains all the changes,
|
||||||
rather than merging in the entire history.
|
rather than merging in the entire history.
|
||||||
+
|
+
|
||||||
If you use '--squash', the merge direction doesn't always have to be
|
If you use '--squash', the merge direction doesn't always have to be
|
||||||
forward; you can use this command to go back in time from v2.5 to v2.4,
|
forward; you can use this command to go back in time from v2.5 to v2.4,
|
||||||
for example. If your merge introduces a conflict, you can resolve it in
|
for example. If your merge introduces a conflict, you can resolve it in
|
||||||
the usual ways.
|
the usual ways.
|
||||||
|
|
||||||
pull::
|
|
||||||
Exactly like 'merge', but parallels 'git pull' in that
|
|
||||||
it fetches the given ref from the specified remote
|
|
||||||
repository.
|
|
||||||
|
|
||||||
push::
|
|
||||||
Does a 'split' (see below) using the <prefix> supplied
|
|
||||||
and then does a 'git push' to push the result to the
|
|
||||||
repository and ref. This can be used to push your
|
|
||||||
subtree to different branches of the remote repository.
|
|
||||||
|
|
||||||
split::
|
split [<local-commit>]::
|
||||||
Extract a new, synthetic project history from the
|
Extract a new, synthetic project history from the
|
||||||
history of the <prefix> subtree. The new history
|
history of the <prefix> subtree of <local-commit>, or of
|
||||||
|
HEAD if no <local-commit> is given. The new history
|
||||||
includes only the commits (including merges) that
|
includes only the commits (including merges) that
|
||||||
affected <prefix>, and each of those commits now has the
|
affected <prefix>, and each of those commits now has the
|
||||||
contents of <prefix> at the root of the project instead
|
contents of <prefix> at the root of the project instead
|
||||||
of in a subdirectory. Thus, the newly created history
|
of in a subdirectory. Thus, the newly created history
|
||||||
is suitable for export as a separate git repository.
|
is suitable for export as a separate git repository.
|
||||||
+
|
+
|
||||||
After splitting successfully, a single commit id is printed to stdout.
|
After splitting successfully, a single commit ID is printed to stdout.
|
||||||
This corresponds to the HEAD of the newly created tree, which you can
|
This corresponds to the HEAD of the newly created tree, which you can
|
||||||
manipulate however you want.
|
manipulate however you want.
|
||||||
+
|
+
|
||||||
Repeated splits of exactly the same history are guaranteed to be
|
Repeated splits of exactly the same history are guaranteed to be
|
||||||
identical (i.e. to produce the same commit ids). Because of this, if
|
identical (i.e. to produce the same commit IDs) as long as the
|
||||||
you add new commits and then re-split, the new commits will be attached
|
settings passed to 'split' (such as '--annotate') are the same.
|
||||||
as commits on top of the history you generated last time, so 'git merge'
|
Because of this, if you add new commits and then re-split, the new
|
||||||
and friends will work as expected.
|
commits will be attached as commits on top of the history you
|
||||||
+
|
generated last time, so 'git merge' and friends will work as expected.
|
||||||
Note that if you use '--squash' when you merge, you should usually not
|
|
||||||
just '--rejoin' when you split.
|
|
||||||
|
|
||||||
|
pull <repository> <remote-ref>::
|
||||||
|
Exactly like 'merge', but parallels 'git pull' in that
|
||||||
|
it fetches the given ref from the specified remote
|
||||||
|
repository.
|
||||||
|
|
||||||
OPTIONS
|
push <repository> [+][<local-commit>:]<remote-ref>::
|
||||||
-------
|
Does a 'split' using the <prefix> subtree of <local-commit>
|
||||||
|
and then does a 'git push' to push the result to the
|
||||||
|
<repository> and <remote-ref>. This can be used to push your
|
||||||
|
subtree to different branches of the remote repository. Just
|
||||||
|
as with 'split', if no <local-commit> is given, then HEAD is
|
||||||
|
used. The optional leading '+' is ignored.
|
||||||
|
|
||||||
|
OPTIONS FOR ALL COMMANDS
|
||||||
|
------------------------
|
||||||
-q::
|
-q::
|
||||||
--quiet::
|
--quiet::
|
||||||
Suppress unnecessary output messages on stderr.
|
Suppress unnecessary output messages on stderr.
|
||||||
|
@ -137,21 +139,16 @@ OPTIONS
|
||||||
want to manipulate. This option is mandatory
|
want to manipulate. This option is mandatory
|
||||||
for all commands.
|
for all commands.
|
||||||
|
|
||||||
-m <message>::
|
OPTIONS FOR 'add' AND 'merge' (ALSO: 'pull', 'split --rejoin', AND 'push --rejoin')
|
||||||
--message=<message>::
|
-----------------------------------------------------------------------------------
|
||||||
This option is only valid for add, merge, pull, and split --rejoin.
|
These options for 'add' and 'merge' may also be given to 'pull' (which
|
||||||
Specify <message> as the commit message for the merge commit.
|
wraps 'merge'), 'split --rejoin' (which wraps either 'add' or 'merge'
|
||||||
|
as appropriate), and 'push --rejoin' (which wraps 'split --rejoin').
|
||||||
|
|
||||||
|
|
||||||
OPTIONS FOR add, merge, and pull
|
|
||||||
--------------------------------
|
|
||||||
--squash::
|
--squash::
|
||||||
This option is only valid for add, merge, and pull
|
Instead of merging the entire history from the subtree project, produce
|
||||||
commands.
|
only a single commit that contains all the differences you want to
|
||||||
+
|
merge, and then merge that new commit into your project.
|
||||||
Instead of merging the entire history from the subtree project, produce
|
|
||||||
only a single commit that contains all the differences you want to
|
|
||||||
merge, and then merge that new commit into your project.
|
|
||||||
+
|
+
|
||||||
Using this option helps to reduce log clutter. People rarely want to see
|
Using this option helps to reduce log clutter. People rarely want to see
|
||||||
every change that happened between v1.0 and v1.1 of the library they're
|
every change that happened between v1.0 and v1.1 of the library they're
|
||||||
|
@ -174,57 +171,53 @@ Whether or not you use '--squash', changes made in your local repository
|
||||||
remain intact and can be later split and send upstream to the
|
remain intact and can be later split and send upstream to the
|
||||||
subproject.
|
subproject.
|
||||||
|
|
||||||
|
-m <message>::
|
||||||
|
--message=<message>::
|
||||||
|
Specify <message> as the commit message for the merge commit.
|
||||||
|
|
||||||
|
OPTIONS FOR 'split' (ALSO: 'push')
|
||||||
|
----------------------------------
|
||||||
|
These options for 'split' may also be given to 'push' (which wraps
|
||||||
|
'split').
|
||||||
|
|
||||||
OPTIONS FOR split
|
|
||||||
-----------------
|
|
||||||
--annotate=<annotation>::
|
--annotate=<annotation>::
|
||||||
This option is only valid for the split command.
|
When generating synthetic history, add <annotation> as a prefix to each
|
||||||
+
|
commit message. Since we're creating new commits with the same commit
|
||||||
When generating synthetic history, add <annotation> as a prefix to each
|
message, but possibly different content, from the original commits, this
|
||||||
commit message. Since we're creating new commits with the same commit
|
can help to differentiate them and avoid confusion.
|
||||||
message, but possibly different content, from the original commits, this
|
|
||||||
can help to differentiate them and avoid confusion.
|
|
||||||
+
|
+
|
||||||
Whenever you split, you need to use the same <annotation>, or else you
|
Whenever you split, you need to use the same <annotation>, or else you
|
||||||
don't have a guarantee that the new re-created history will be identical
|
don't have a guarantee that the new re-created history will be identical
|
||||||
to the old one. That will prevent merging from working correctly. git
|
to the old one. That will prevent merging from working correctly. git
|
||||||
subtree tries to make it work anyway, particularly if you use --rejoin,
|
subtree tries to make it work anyway, particularly if you use '--rejoin',
|
||||||
but it may not always be effective.
|
but it may not always be effective.
|
||||||
|
|
||||||
-b <branch>::
|
-b <branch>::
|
||||||
--branch=<branch>::
|
--branch=<branch>::
|
||||||
This option is only valid for the split command.
|
After generating the synthetic history, create a new branch called
|
||||||
+
|
<branch> that contains the new history. This is suitable for immediate
|
||||||
After generating the synthetic history, create a new branch called
|
pushing upstream. <branch> must not already exist.
|
||||||
<branch> that contains the new history. This is suitable for immediate
|
|
||||||
pushing upstream. <branch> must not already exist.
|
|
||||||
|
|
||||||
--ignore-joins::
|
--ignore-joins::
|
||||||
This option is only valid for the split command.
|
If you use '--rejoin', git subtree attempts to optimize its history
|
||||||
+
|
reconstruction to generate only the new commits since the last
|
||||||
If you use '--rejoin', git subtree attempts to optimize its history
|
'--rejoin'. '--ignore-joins' disables this behavior, forcing it to
|
||||||
reconstruction to generate only the new commits since the last
|
regenerate the entire history. In a large project, this can take a long
|
||||||
'--rejoin'. '--ignore-join' disables this behaviour, forcing it to
|
time.
|
||||||
regenerate the entire history. In a large project, this can take a long
|
|
||||||
time.
|
|
||||||
|
|
||||||
--onto=<onto>::
|
--onto=<onto>::
|
||||||
This option is only valid for the split command.
|
If your subtree was originally imported using something other than git
|
||||||
+
|
subtree, its history may not match what git subtree is expecting. In
|
||||||
If your subtree was originally imported using something other than git
|
that case, you can specify the commit ID <onto> that corresponds to the
|
||||||
subtree, its history may not match what git subtree is expecting. In
|
first revision of the subproject's history that was imported into your
|
||||||
that case, you can specify the commit id <onto> that corresponds to the
|
project, and git subtree will attempt to build its history from there.
|
||||||
first revision of the subproject's history that was imported into your
|
|
||||||
project, and git subtree will attempt to build its history from there.
|
|
||||||
+
|
+
|
||||||
If you used 'git subtree add', you should never need this option.
|
If you used 'git subtree add', you should never need this option.
|
||||||
|
|
||||||
--rejoin::
|
--rejoin::
|
||||||
This option is only valid for the split command.
|
After splitting, merge the newly created synthetic history back into
|
||||||
+
|
your main project. That way, future splits can search only the part of
|
||||||
After splitting, merge the newly created synthetic history back into
|
history that has been added since the most recent '--rejoin'.
|
||||||
your main project. That way, future splits can search only the part of
|
|
||||||
history that has been added since the most recent --rejoin.
|
|
||||||
+
|
+
|
||||||
If your split commits end up merged into the upstream subproject, and
|
If your split commits end up merged into the upstream subproject, and
|
||||||
then you want to get the latest upstream version, this will allow git's
|
then you want to get the latest upstream version, this will allow git's
|
||||||
|
@ -235,13 +228,12 @@ Unfortunately, using this option results in 'git log' showing an extra
|
||||||
copy of every new commit that was created (the original, and the
|
copy of every new commit that was created (the original, and the
|
||||||
synthetic one).
|
synthetic one).
|
||||||
+
|
+
|
||||||
If you do all your merges with '--squash', don't use '--rejoin' when you
|
If you do all your merges with '--squash', make sure you also use
|
||||||
split, because you don't want the subproject's history to be part of
|
'--squash' when you 'split --rejoin'.
|
||||||
your project anyway.
|
|
||||||
|
|
||||||
|
|
||||||
EXAMPLE 1. Add command
|
EXAMPLE 1. 'add' command
|
||||||
----------------------
|
------------------------
|
||||||
Let's assume that you have a local repository that you would like
|
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
|
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-subtree repository as a subdirectory of your already existing
|
||||||
|
@ -253,15 +245,15 @@ git-extensions repository in ~/git-extensions/:
|
||||||
'master' needs to be a valid remote ref and can be a different branch
|
'master' needs to be a valid remote ref and can be a different branch
|
||||||
name
|
name
|
||||||
|
|
||||||
You can omit the --squash flag, but doing so will increase the number
|
You can omit the '--squash' flag, but doing so will increase the number
|
||||||
of commits that are included in your local repository.
|
of commits that are included in your local repository.
|
||||||
|
|
||||||
We now have a ~/git-extensions/git-subtree directory containing code
|
We now have a ~/git-extensions/git-subtree directory containing code
|
||||||
from the master branch of git://github.com/apenwarr/git-subtree.git
|
from the master branch of git://github.com/apenwarr/git-subtree.git
|
||||||
in our git-extensions repository.
|
in our git-extensions repository.
|
||||||
|
|
||||||
EXAMPLE 2. Extract a subtree using commit, merge and pull
|
EXAMPLE 2. Extract a subtree using 'commit', 'merge' and 'pull'
|
||||||
---------------------------------------------------------
|
---------------------------------------------------------------
|
||||||
Let's use the repository for the git source code as an example.
|
Let's use the repository for the git source code as an example.
|
||||||
First, get your own copy of the git.git repository:
|
First, get your own copy of the git.git repository:
|
||||||
|
|
||||||
|
@ -269,7 +261,7 @@ First, get your own copy of the git.git repository:
|
||||||
$ cd test-git
|
$ cd test-git
|
||||||
|
|
||||||
gitweb (commit 1130ef3) was merged into git as of commit
|
gitweb (commit 1130ef3) was merged into git as of commit
|
||||||
0a8f4f0, after which it was no longer maintained separately.
|
0a8f4f0, after which it was no longer maintained separately.
|
||||||
But imagine it had been maintained separately, and we wanted to
|
But imagine it had been maintained separately, and we wanted to
|
||||||
extract git's changes to gitweb since that time, to share with
|
extract git's changes to gitweb since that time, to share with
|
||||||
the upstream. You could do this:
|
the upstream. You could do this:
|
||||||
|
@ -279,14 +271,14 @@ the upstream. You could do this:
|
||||||
--branch gitweb-latest
|
--branch gitweb-latest
|
||||||
$ gitk gitweb-latest
|
$ gitk gitweb-latest
|
||||||
$ git push git@github.com:whatever/gitweb.git gitweb-latest:master
|
$ git push git@github.com:whatever/gitweb.git gitweb-latest:master
|
||||||
|
|
||||||
(We use '0a8f4f0^..' because that means "all the changes from
|
(We use '0a8f4f0^..' because that means "all the changes from
|
||||||
0a8f4f0 to the current version, including 0a8f4f0 itself.")
|
0a8f4f0 to the current version, including 0a8f4f0 itself.")
|
||||||
|
|
||||||
If gitweb had originally been merged using 'git subtree add' (or
|
If gitweb had originally been merged using 'git subtree add' (or
|
||||||
a previous split had already been done with --rejoin specified)
|
a previous split had already been done with '--rejoin' specified)
|
||||||
then you can do all your splits without having to remember any
|
then you can do all your splits without having to remember any
|
||||||
weird commit ids:
|
weird commit IDs:
|
||||||
|
|
||||||
$ git subtree split --prefix=gitweb --annotate='(split) ' --rejoin \
|
$ git subtree split --prefix=gitweb --annotate='(split) ' --rejoin \
|
||||||
--branch gitweb-latest2
|
--branch gitweb-latest2
|
||||||
|
@ -313,7 +305,7 @@ And fast forward again:
|
||||||
$ git subtree merge --prefix=gitweb --squash gitweb-latest
|
$ git subtree merge --prefix=gitweb --squash gitweb-latest
|
||||||
|
|
||||||
And notice that your change is still intact:
|
And notice that your change is still intact:
|
||||||
|
|
||||||
$ ls -l gitweb/myfile
|
$ ls -l gitweb/myfile
|
||||||
|
|
||||||
And you can split it out and look at your changes versus
|
And you can split it out and look at your changes versus
|
||||||
|
@ -321,8 +313,8 @@ the standard gitweb:
|
||||||
|
|
||||||
git log gitweb-latest..$(git subtree split --prefix=gitweb)
|
git log gitweb-latest..$(git subtree split --prefix=gitweb)
|
||||||
|
|
||||||
EXAMPLE 3. Extract a subtree using branch
|
EXAMPLE 3. Extract a subtree using a branch
|
||||||
-----------------------------------------
|
-------------------------------------------
|
||||||
Suppose you have a source directory with many files and
|
Suppose you have a source directory with many files and
|
||||||
subdirectories, and you want to extract the lib directory to its own
|
subdirectories, and you want to extract the lib directory to its own
|
||||||
git project. Here's a short way to do it:
|
git project. Here's a short way to do it:
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -23,9 +23,9 @@
|
||||||
|
|
||||||
"pull" and "merge" commands should fail if you've never merged
|
"pull" and "merge" commands should fail if you've never merged
|
||||||
that --prefix before
|
that --prefix before
|
||||||
|
|
||||||
docs should provide an example of "add"
|
docs should provide an example of "add"
|
||||||
|
|
||||||
note that the initial split doesn't *have* to have a commitid
|
note that the initial split doesn't *have* to have a commitid
|
||||||
specified... that's just an optimization
|
specified... that's just an optimization
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
get a misleading "prefix must end with /" message from
|
get a misleading "prefix must end with /" message from
|
||||||
one of the other git tools that git-subtree calls. Should
|
one of the other git tools that git-subtree calls. Should
|
||||||
detect this situation and print the *real* problem.
|
detect this situation and print the *real* problem.
|
||||||
|
|
||||||
"pull --squash" should do fetch-synthesize-merge, but instead just
|
"pull --squash" should do fetch-synthesize-merge, but instead just
|
||||||
does "pull" directly, which doesn't work at all.
|
does "pull" directly, which doesn't work at all.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue