HiveBrain v1.2.0
Get Started
← Back to all entries
snippetbashTip

git subtree — Merge subtrees together or split repository into subtrees. More information: <https://manned.org/git

Submitted by: @import:tldr-pages··
0
Viewed 0 times
git subtreesubtreescommandsplitclimergetogetherrepository

Problem

How to use the git subtree command: Merge subtrees together or split repository into subtrees. More information: <https://manned.org/git-subtree>.

Solution

git subtree — Merge subtrees together or split repository into subtrees. More information: <https://manned.org/git-subtree>.

Add a Git repository as a subtree and squash the commits together:
git subtree add {{[-P|--prefix]}} {{path/to/directory}} --squash {{repository_url}} {{branch_name}}


Update subtree repository to its latest commit:
git subtree pull {{[-P|--prefix]}} {{path/to/directory}} {{repository_url}} {{branch_name}}


Merge recent changes up to the latest subtree commit into the subtree:
git subtree merge {{[-P|--prefix]}} {{path/to/directory}} --squash {{repository_url}} {{branch_name}}


Push commits to a subtree repository:
git subtree push {{[-P|--prefix]}} {{path/to/directory}} {{repository_url}} {{branch_name}}


Extract a new project history from the history of a subtree:
git subtree split {{[-P|--prefix]}} {{path/to/directory}} {{repository_url}} {{[-b|--branch]}} {{branch_name}}

Code Snippets

Add a Git repository as a subtree and squash the commits together

git subtree add {{[-P|--prefix]}} {{path/to/directory}} --squash {{repository_url}} {{branch_name}}

Update subtree repository to its latest commit

git subtree pull {{[-P|--prefix]}} {{path/to/directory}} {{repository_url}} {{branch_name}}

Merge recent changes up to the latest subtree commit into the subtree

git subtree merge {{[-P|--prefix]}} {{path/to/directory}} --squash {{repository_url}} {{branch_name}}

Push commits to a subtree repository

git subtree push {{[-P|--prefix]}} {{path/to/directory}} {{repository_url}} {{branch_name}}

Extract a new project history from the history of a subtree

git subtree split {{[-P|--prefix]}} {{path/to/directory}} {{repository_url}} {{[-b|--branch]}} {{branch_name}}

Context

tldr-pages: common/git subtree

Revisions (0)

No revisions yet.