简体   繁体   中英

Merging commit to a remote forked repository

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?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM