Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to push to git subtree?

I added a subtree on git which seems to be working. I went into the directory and made some changes and then pushed.

I noticed these changes show up in the parent project but the repository which I used as the source hasn't been updated.

I tried git subtree push which returns:

You must provide the --prefix option.

Also git subtree push --prefix=my/folder [email protected] which returns:

You must provide <repository> <ref>

What is the correct way to push changes to the origin repo for my git subtree?

Edit: it was suggested that I do:

git subtree push --prefix=my/folder origin master

When I run the above it starts the process but ends up saying the branch is behind. So I run:

git subtree pull --prefix=my/folder origin master

Which returns "Already up to date"

like image 248
Philip Kirkbride Avatar asked Feb 03 '17 14:02

Philip Kirkbride


1 Answers

So, with some joint effort with @PhilipKirkbride, here's what we managed to figure out:

You need to put all the details in the command:

git subtree push --prefix=my/folder subtree_origin master

Where master is the branch in the subtree, and subtree_origin is just another remote, which happens to point to your subtree's git repository. You can also type the full repo URL.

like image 86
Dan Avatar answered Sep 19 '22 16:09

Dan