2020-05-03 13:55:53 +01:00
|
|
|
# git subtree
|
|
|
|
|
|
|
|
> Tool to manage project dependencies as subprojects.
|
2023-11-06 17:44:12 +00:00
|
|
|
> More information: <https://manpages.debian.org/latest/git-man/git-subtree.1.html>.
|
2020-05-03 13:55:53 +01:00
|
|
|
|
2021-01-07 14:06:38 +00:00
|
|
|
- Add a Git repository as a subtree:
|
2020-05-03 13:55:53 +01:00
|
|
|
|
2020-10-19 19:26:01 +01:00
|
|
|
`git subtree add --prefix={{path/to/directory/}} --squash {{repository_url}} {{branch_name}}`
|
2020-05-03 13:55:53 +01:00
|
|
|
|
|
|
|
- Update subtree repository to its latest commit:
|
|
|
|
|
2020-10-19 19:26:01 +01:00
|
|
|
`git subtree pull --prefix={{path/to/directory/}} {{repository_url}} {{branch_name}}`
|
2020-05-03 13:55:53 +01:00
|
|
|
|
2020-10-19 19:26:01 +01:00
|
|
|
- Merge recent changes up to the latest subtree commit into the subtree:
|
2020-05-03 13:55:53 +01:00
|
|
|
|
2020-10-19 19:26:01 +01:00
|
|
|
`git subtree merge --prefix={{path/to/directory/}} --squash {{repository_url}} {{branch_name}}`
|
2020-05-03 13:55:53 +01:00
|
|
|
|
|
|
|
- Push commits to a subtree repository:
|
|
|
|
|
2020-10-19 19:26:01 +01:00
|
|
|
`git subtree push --prefix={{path/to/directory/}} {{repository_url}} {{branch_name}}`
|
2020-05-03 13:55:53 +01:00
|
|
|
|
|
|
|
- Extract a new project history from the history of a subtree:
|
|
|
|
|
|
|
|
`git subtree split --prefix={{path/to/directory/}} {{repository_url}} -b {{branch_name}}`
|