Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between "git subtree pull" and "git pull -s subtree"

We are having an issue where the command:

git subtree pull --prefix=Root squash root master

is pulling code from the root repository into the . directory of our repository instead of the Root directory.

This command has worked fine in the past. The only difference is it has been a while since we have done a pull, so there are quite a few changes to merge.

I can't seem to find any official documentation on "git subtree", but there is a lot on the subtree merge strategy used with "git pull -s subtree". What is the difference (if any)?

like image 556
Joe Enzminger Avatar asked Feb 18 '15 20:02

Joe Enzminger


People also ask

How do you pull a subtree?

Adding a subtreeSpecify the prefix local directory into which you want to pull the subtree. Specify the remote repository URL [of the subtree being pulled in] Specify the remote branch [of the subtree being pulled in] Specify you want to squash all the remote repository's [the subtree's] logs.

How does git Subtrees work?

git subtree lets you nest one repository inside another as a sub-directory. It is one of several ways Git projects can manage project dependencies. Management of a simple workflow is easy. Older version of Git are supported (even older than v1.

Is git pull the same as fetch and merge?

The git pull command first runs git fetch which downloads content from the specified remote repository. Then a git merge is executed to merge the remote content refs and heads into a new local merge commit.

What is git subtree split?

Splitting the Original Repository The subtree commands effectively take a folder and split to another repository. Everything you want in the subtree repo will need to be in the same folder.


1 Answers

git subtree is an "alternative to submodules", see https://github.com/git/git/blob/master/contrib/subtree/git-subtree.txt or https://medium.com/@porteneuve/mastering-git-subtrees-943d29a798ec

git pull -s subtree or git merge -s subtree selects the subtree merge strategy: http://git-scm.com/book/en/v1/Git-Tools-Subtree-Merging

See also the answer to When to use git subtree?

like image 97
drRobertz Avatar answered Oct 28 '22 22:10

drRobertz