0

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).

1 Answer 1

1

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 
Sign up to request clarification or add additional context in comments.

2 Comments

So say in PLATFORM2_7_0_3 I have a sub-branch called PLATFORM2_7_0_3_fix (which contains the commit) and I want to cherry pick that sub branch which contains the fix into the PLATFORM2_7_1_1, how would I do that?
@PaulStatham: git cherry-pick PLATFORM2_7_0_3_fix for the last commit, else use git merge PLATFORM2_7_0_3_fix.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.