franka
franka

Reputation: 1917

Bitbucket: Update a fork to merge changes of master repo?

I am working with a bitbucket git repo I have read-only access to, so I created a fork to work on my features.

Question: How do I update my fork to include changes made to the original repo made by the owner?

On github, it seems one has to do the following, so I suspect it's a similar to this:

 $ git remote add upstream git://github.com/octocat/Spoon-Knife.git
 $ git fetch upstream
 $ git merge upstream/master

I couldn't find any information on this in the Bitbucket Documentation for forking

Upvotes: 55

Views: 33826

Answers (7)

Vinod Kumar
Vinod Kumar

Reputation: 592

Here comes the easiest way...

  1. Go to your forked repo.
  2. Select Repository Settings.
  3. Select Fork syncing tab.
  4. Uncheck Enable fork syncing toggle.
  5. Check Enable fork syncing toggle again.

It should update the Last automatic synchronization timestamp.

Upvotes: 7

Jay K
Jay K

Reputation: 33

In Bitbucket, using the "Enable Fork Syncing" feature for your forked repo makes it super easy to pull new changes from the original repo into the forked repo.

e.g.

  1. There is an original repo, and you create a forked repo. While creating a fork on the bitbucket website, there is a check box for "Enable Fork Syncing", please check it.
  2. Next, clone the forked repo into your local and create a feature branch from the master branch.
(master) $ git checkout -b feature
  1. Anytime you want to pull new commits from the original repo into the master branch, run the below commands:
# below git command will fetch all the changes from the original repo's master branch 
# into your local's master branch because we had enabled fork syncing.
(feature) $ git fetch origin master:master

# use merge or rebase as per your preference
(feature) $ git rebase master

Documentation @ https://confluence.atlassian.com/bitbucketserver/keeping-forks-synchronized-776639961.html

Upvotes: 0

Deepika Gupta
Deepika Gupta

Reputation: 21

On Repository settings -> Fork Syncing Uncheck & check option "Enable fork syncing"

You will see a message Last automatic synchronization: a moment ago

Upvotes: 1

gonzalo.vinas
gonzalo.vinas

Reputation: 71

On the left hand side, the repository details panels shows a SYNC button IF AND ONLY IF there is any commit behind

enter image description here

Upvotes: 3

Andreas
Andreas

Reputation: 2153

In the latest version there is a Repository-Details box on the right side with a sync button if the root has unmerged updates.

Upvotes: 2

soch guru
soch guru

Reputation: 211

  1. Goto your fork on bitbucket
  2. Click the Branches menu from the left navigation pane
  3. Click on the "..." button to the right of the branch and select "Compare". Or, in the url add the word “compare”. So that the URL looks like this: https://bitbucket.org/<user name>/<fork name>/branches/compare
  4. Click on the switch icon (black up/down arrows between the branch segments) so that the blue arrow is pointing into your fork
  5. Select the correct branches in your fork and the owner's repo
  6. Click Compare
  7. Click Merge

Upvotes: 19

Martin Geisler
Martin Geisler

Reputation: 73748

Just like GitHub, you have to pull the commits down to your own machine, merge, and then push them back to your fork on Bitbucket.

If you go to your fork on Bitbucket you can click "compare fork" to get to a page where you see incoming and outgoing commits. If you go to the "incoming" tab, you will see instructions like

$ git remote add <remote_name> [email protected]:<upstream>/<repo>.git
$ git fetch <remote_name>
$ git checkout master
$ git merge <remote_name>/master

which correspond closely to the GitHub instructions.

Upvotes: 69

Related Questions