LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

git-subtree

Merge and split repositories using subdirectories

TLDR

Add subtree
$ git subtree add --prefix=[dir] [repo] [branch]
copy
Pull subtree changes
$ git subtree pull --prefix=[dir] [repo] [branch]
copy
Push subtree changes
$ git subtree push --prefix=[dir] [repo] [branch]
copy
Split subtree
$ git subtree split --prefix=[dir] -b [new_branch]
copy
Merge subtree
$ git subtree merge --prefix=[dir] [commit]
copy

SYNOPSIS

git subtree command [options]

DESCRIPTION

git subtree merges and splits repositories into subdirectories, providing an alternative to submodules. Unlike submodules, subtrees keep everything in a single repository with a unified history.The `split` command extracts the history of a subdirectory into a separate branch, while `add`, `pull`, and `push` manage the ongoing synchronization with the upstream repository.

PARAMETERS

--prefix dir

Subdirectory for subtree.
--squash
Squash history.
-b branch
Branch name for split.

SUBCOMMANDS

add

Add repository as subtree.
pull
Pull subtree changes.
push
Push subtree changes.
merge
Merge subtree changes.
split
Extract subtree history.

SEE ALSO

Copied to clipboard
Kai