Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update a git subtree branch with new commits from the original branch

I'm working on dividing part of my main repository into another one. I'm using git subtree to do the work.

So I created a subtree branch with the following command:

git checkout master
git subtree split -P ./Foo -b subtreeBranch

A new branch is created with the content of Foo, named as subtreeBranch.

But later some changes have been added into the original branch(master), onto the files inside Foo.

How can I update the subtreeBranch with the new commits?

like image 779
Xun Yang Avatar asked Oct 14 '25 04:10

Xun Yang


1 Answers

I managed to fix i by running git subtree split again on the original branch. As stated in the git subtree reference regarding split:

Repeated splits of exactly the same history are guaranteed to be identical (i.e. to produce the same commit ids). Because of this, if you add new commits and then re-split, the new commits will be attached as commits on top of the history you generated last time, so 'git merge' and friends will work as expected.

However running git subtree is a very slow process, probably related to the size of my project.

like image 152
Xun Yang Avatar answered Oct 17 '25 05:10

Xun Yang



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!