PDStat
PDStat

Reputation: 5825

Merging commit into separate git repository

So I have a single git repository with multiple branches, from this I have created a number of local repositories just selecting a single branch at a time, for example

git clone --single-branch --branch master ssh://xxx:29418/Javacode.git master
git clone --single-branch --branch PLATFORM2_7_0_3 ssh://xxx:29418/Javacode.git PLATFORM2_7_0_3
git clone --single-branch --branch PLATFORM2_7_1_1 ssh://xxx:29418/Javacode.git PLATFORM2_7_1_1

Now say I do a commit in one of those repositories and I wish to take that commit and put it in one of the other repositories.

Now I am new to git but from what I understand what one would usually do is take the entire repository (i.e. without the single-branch option), checkout a certain branch, create a new branch from that, do a commit to that branch, then merge the new branch with the original. It should then also be possible to checkout say the 7_1_1 branch or the main branch and again merge the branch with the fix in it to those.

Because of the way I'm cloning single branches into separate repositories, what method can I use to achieve the above, without having to make the same changes in these repositories (which would of course be prone to error).

Upvotes: 0

Views: 56

Answers (1)

Fred Foo
Fred Foo

Reputation: 363487

Within one of these clones, you can fetch the entire upstream repo with

git fetch origin

You then have all the commits that origin has and you can git cherry-pick them.

If the commit lives not in origin but in, say, the PLATFORM2_7_0_3 clone, you can cherry-pick it into one of the other clones by adding that as a remote:

cd PLATFORM2_7_1_1
git remote add PLATFORM2_7_0_3 ../PLATFORM2_7_0_3

Upvotes: 1

Related Questions