# Git Subtrees

Using Git Subtree is more preferable to using Git Submodules as it gives more control on embedding projects and their updates. The manual is based on the articles:

# Adding the second repository as a subtree

Add a new repository as a remote upstream:

git remote add <remote_name> <git_url>

Make sure you commit all changes:

git status

If no then commit the changes.

Connect subtree to a folder:

git subtree add --prefix=<folder> <remote_namee> <git_branch>

Use master as a git_branch.

# Push local changes to subtree

Perform an ordinary commit:

git commit -a

Push subtree changes to the source repository:

git subtree push --prefix=<folder> <remote_name> <git_branch>

# Pull of subtree changes

Make sure you commit all changes:

git status

Upload commits from an external repository:

git subtree pull --squash --prefix=<folder> <remote_name> <git_branch>