GIT Updating subree: how can I update my subtree?
We have a few repo’s like :
As you see lib is shared in both sites. Now when I use
[master] git fetch lib
After that I use :
[master] git merge --squash -s subtree --no-commit lib
Then it starts deleting loads of files that belongs to the site.
If I try this:
Update the Library Sub-Project from the Shared Library Remote
[master] git checkout lib Checking out files: 100% (4521/4521), done. Switched to branch 'lib' [lib] git pull Already up-to-date.
Then just checkout to the master, and run the command:
git merge --squash -s subtree --no-commit lib
This just deletes a whole load of files from my site and leaves a few files like its in a subfolder of lib..
Why doesen’t this just update the lib to the correct version? and leave the files for the site?
After a reset I do get my project back
git reset --hard origin/master
How can I update the lib?
There is a remote branch setup.
$ git remote -v lib https://github.com/***/lib.git (fetch) lib https://github.com/***/lib.git (push)
One Solution collect form web for “GIT Updating subree: how can I update my subtree?”
Considering that you already set your subtree in your app (
git remote add subtree_name firstname.lastname@example.org:user/subtree_proj.git) your have to:
1- Subtree split
git subtree split -P lib -b new_branch_to_split where the
lib is the path to your subtree project and the
new_branch_to_split will only contain your
lib code and will be pushed to your
2- Subtree push
git push subtree_name new_branch_to_split:original_subtree_branch(i.e. master)
git push subtree_name new_branch_to_split:master
3- Always delete the temporary branch
git branch -D new_branch_to_split
4- Pull the changes in your other project that’s using the subtree project
git subtree pull -P lib subtree_name original_subtree_branch(i.e. master)