Skip to content

Instantly share code, notes, and snippets.

@kjantzer
Last active September 22, 2015 17:29
Show Gist options
  • Select an option

  • Save kjantzer/8dc9bc794ba31e0edb19 to your computer and use it in GitHub Desktop.

Select an option

Save kjantzer/8dc9bc794ba31e0edb19 to your computer and use it in GitHub Desktop.
Git Subtree Tips

Git SubTrees

Better than submodules a large majority of the time.

Follow this article to setup a subtree:
http://lostechies.com/johnteague/2014/04/04/using-git-subtrees-to-split-a-repository/

The core principles are, once the subtree code is in it's own repo, perform these actions:

git remote add SubtreeName <url_to_lib_remote>
git rm -r subtree/dir
git add -A
git commit -am "removing subtree folder and contents"
git subtree add --prefix=subtree/dir SubtreeName master

Push subtree changes to subtree repo

git subtree push -P subtree/dir SubtreeName master

Pull subtree changes into root repo

git subtree pull -P subtree/dir SubtreeName master

Note: vim will be used to save the "merge message".
Press esc and then type :x for save and quit.

Force push subtree when "non-fastforward" message appears

git push SubtreeName `git subtree split -P subtree/dir  master`:master --force

from:http://stackoverflow.com/a/15623469/484780

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment