Small utility for publishing a subtree of your repository as a new git repository.


  1. Clone the project
  2. Add git-publish-subtree/bin to your path.


git clone https://bitbucket.org/tpettersen/git-publish-subtree ~/git-publish-subtree
export PATH=$PATH:~/git-publish-subtree/bin

Then you can use publish-subtree just like any other git command.


git publish-subtree plugins/jira-integration git@bitbucket.org:atlassian/jira-integration.git


Usage: git publish-subtree [<subtree>] <remote>

If <subtree> is omitted, the current directory will be used.

The new repository will be pushed to <remote>.


  • The <remote> repository must either:

    • be empty; or
    • have been the target of a previous git publish-subtree invocation from the same <subtree> from a commit somewhere in the history of your
      default branch,
      otherwise the push will fail due to a non-fast-forward merge.
  • The <remote> should be put into read-only mode between updates by
    git publish-subtree. There is currently no way to integrate changes to the <remote> back into your project.

  • Any tags not containing the <subtree> will be ignored.


  • There is currently no way to force an update of the <remote>. If you have divergent history, you'll have to manually fix-up the remote before you running this command. (or hack the script and add a -f to the push)
  • Only the default branch (currently hard-coded to master) and any tags
    present in the local repository will be pushed to <remote>.