diff --git a/pages/common/git-subtree.md b/pages/common/git-subtree.md new file mode 100644 index 0000000000..78ad587c25 --- /dev/null +++ b/pages/common/git-subtree.md @@ -0,0 +1,24 @@ +# git subtree + +> Tool to manage project dependencies as subprojects. +> More information: <https://manpages.debian.org/testing/git-man/git-subtree.1.en.html>. + +- Add a git repository as a subtree: + +`git subtree add --prefix={{path/to/directory/}} --squash {{repository_url}} {{master}}` + +- Update subtree repository to its latest commit: + +`git subtree pull --prefix={{path/to/directory/}} {{repository_url}} {{master}}` + +- Merge a subtree repository into master: + +`git subtree merge --prefix={{path/to/directory/}} --squash {{repository_url}} {{master}}` + +- Push commits to a subtree repository: + +`git subtree push --prefix={{path/to/directory/}} {{repository_url}} {{master}}` + +- Extract a new project history from the history of a subtree: + +`git subtree split --prefix={{path/to/directory/}} {{repository_url}} -b {{branch_name}}`