Creating pull requests for code reviews in Git

Objective :

This page explains about how to fork a repository and use pull request feature of Bitbucket.

Description:

  1. Login to Bitbucket and open your repository. Select Fork option visible at right top of the page.
  2. Give the details and fork it. Now you will see a repository in your repositories list.
  3. Give access to forked repository to  your all the users of the the repository at access management of Repository Settings.
  4. Goto Defaults reviewers and add the reviewers to the forked repository to be merged with original repository.
  5. Users can now the clone the repository and start using it.
  6. Once the clone is done can List the current configured remote repository for your fork using below command.
    git remote -v

    origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
    origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)

  7. Now add the upstream using below repository
    git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
  8. After adding the upstream repository
    "git remote -v" will show the below

    origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
    origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
    upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (fetch)
    upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (push)

  9. Now update the repository and push to forked repository.
  10. Fetch the Original Repository using
    git merge upstream/master
  11. Goto Bitbucket and Select pull request for merging the update to original repository.
  12. Reviewer/admins  reviews,approves and merges it.
  13. To fetch the updated files from Original repository use the below command
    git merge upstream/master

Reference:

https://help.github.com/articles/syncing-a-fork/

https://help.github.com/articles/configuring-a-remote-for-a-fork/

Leave a Reply

Your email address will not be published. Required fields are marked *