0

I have a git repository on BitBucket with multiple branches and I want to fork this repository with all its branches to give an access to an external collaborator. My question is it possible to merge a commit from a specific branch of the original repository to the forked one knowing that that nothing has changed in the forked repository? If yes, what are the necessary steps to do that?

  • Possible duplicate of [Merge git repo into branch of another repo](https://stackoverflow.com/questions/21353656/merge-git-repo-into-branch-of-another-repo) – phd Mar 21 '18 at 14:17

2 Answers2

1

Yes, you can pull commits from the original repository. There are two ways to do this:

  1. Create a pull request in the forked repo from the original.

  2. Clone the forked repo to a local repo. Then add a remote for the original:

    $ git clone <forked repo URL>
    $ git remote add upstream <original repo URL>
    

    Now you have two remotes. origin refers to your forked repo and upstream refers to the original. To merge from the original into your forked repo do this:

    $ git checkout my-branch
    $ git pull upstream my-branch
    $ git push origin my-branch
    

Instead of my-branch, you can put any branch name you wish.

Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268
1

If I understand correctly, you want to merge branch-a from local original-repo to branch-b of remote forked-repo.

If so, this may be a duplicate of: Merge git repo into branch of another repo

Joshua Manns
  • 525
  • 4
  • 6