Add/Update Git Subtree

Recently I am working on WordPress development helper library, I add it as submodule in many of my plugins, but every time during clone i forgot to init and update submodule, and some time during pull code i forgot to update new submodule. So, Finally i decided to start use Git Subtree.

Following are the set of command that will required during development and working with subtree

Add git subtree in repo

git subtree add --prefix app/lib https://github.com/rtCamp/wp-helpers.git master --squash

Update git subtree in repo

git subtree pull --prefix app/lib https://github.com/rtCamp/wp-helpers.git master --squash

FYI: There are some pros and cons of subtree and submodule, You can find many article on it just google it 😉