GitCheatSheet.org logo
Home / How To

Pull a subtree

git subtree pull --prefix my-nested-repo https://gitcheatsheet.org/example-git-repository.git main --squash

Pulls the "main" branch of the repository specified in the url into a local directory called "my-nested-repo", squashing the history of the pulled repository. Note: instead of specifying the url directly, you can use a remote name, if configured.