I have the following situation:
You can see that I am working on <red_project>
. First I was working on it in <green_team>
but due to a reorganization I now belong to <blue_team>
.
Three days ago, IT moved the code up until commit dad25697af4
from the <green_team>
to the <blue_team>
repository directory. But since then a few more commits have been made to the code in the <green_team>
repository.
How do I transfer these latest commits to the <blue_team>
repository?
Currently in my shell I see the following:
<red_project>$ git remote -v
origin ssh://git@git.<purple>.com:<port>/<green_team>/<red_project>.git (fetch)
origin ssh://git@git.<purple>.com:<port>/<green_team>/<red_project>.git (push)
I guess I probably need to add ssh://git@git.<purple>.com:<port>/<blue_team>/<red_project>.git
as a new remote, but not sure of the next steps then.
I would switch to the <blue_team>
repository, add the <green_team>
repository as a new remote reference:
git remote add origin_green ssh://git@git.<purple>.com:<port>/<blue_team>/<red_project>.git
I would then fetch just the data i needed from that remote, as per How do I fetch only one branch of a remote Git repository?
git fetch origin_green <branch_name>
Then i would cherry-pick the commit, or range of commits (How to cherry pick a range of commits and merge into another branch?), into the matching branch on origin_green
.
If no work has been done (or is being done) on the <blue_team>
repository, you might also just as well git reset --hard origin_green/<branch_name>
.
Finally, remove the origin_green
remote reference:
git remote remove origin_green