gitbashgithubmigration.git-info-grafts

Cloning a GIT branch to another repositories GIT branch?


I have two GIT repositories, one for work and one for independent development. My company expressed interest in a project I've been working on and would like me to migrate that branch (master) into a new branch on their repo (Features/Dynamo). I have created a migrator in the past but this clobbers the repo being pushed to as it is a straight --bare then --mirror. What would I need to do in order to graft a branch from one repository to another (while creating the new branch in the process)?


Solution

  • Another approach is to add the other remote.

    git remote add ehime https://github.com/your_username/your_repo_name.git
    

    Now all the stuff you've done like

    git push origin some_branch
    

    can also be done as

    git push ehime some_branch
    

    for the other remote.

    Thus two remotes but one directory of code.

    In the case of shared files there are lots of options when doing a merge such as

    git checkout branchA
    git merge ours branchB
    

    or

    git checkout branchA
    git merge -X theirs branchB
    

    to control how merges are done between the two codebases.