When working in a larger organization, a well-built pull request is important. Many organizations use pull requests for code review, so your team members can review the changes you made and provide feedback.

 

Create a Team Pull Request

Opening a pull request for your team to review:

  1. In the repository, click on the file you want to modify (e.g. README)
  2. Click the Edit button
  3. Add your changes to it
  4. Add commit changes message. Example: “Adds a small message to the README”
  5. Create branch for it by checking: “Create a new branch for this commit and start a pull request”.
  6. Press Propose file change button
  7. In the Open a pull request page, try to be clear in your message what you’re changing and why you’re changing it.
  8. Use team mentions to address team members or an entire team in your message (e.g. @kdaigle-inc/developers or @omaralbeik).
  9. Press Create pull request button.

 

Review Team Pull Request

If you’re part of the team that was mentioned in the previous request, you can pull the changes down to the local repository and do the following:

  1. Open the remote repository
  2. Code view > Copy to clipboard button to copy the repo url
  3. In your terminal type:
    git clone <paste clipboard url>
  4. Enter your local repository
  5. Check branches
    git branch
    
    * master

    Only the master branch has been cloned..

  6. When we do a git clone, we don’t get the remote branch locally, so:
    git branch --remote
  7. Check out new branch
  8. git checkout updated-readme
  9. Apply changes to local repo files
  10. Push changes
    git status
    git add .
    git commit -m "added team members"
    git push origin updated-readme
  11. On GitHub, open the pull request, you should see your commit pushed up.
  12. Review message: Let the team know that you reviewed the pull request by adding a message.
  13. Now it’s up to a teammate to merge the pull request and then delete the branch – deleted branches can be restored through the Restore branch button.

 

Fetch Command

When you don’t know about a new branch yet, you need to `git fetch` to get the branches locally and then `git checkout` to move your local copy over to the branch you’d like to be on.

git fetch; git checkout

 

Commits: A Project History

After merging a pull request, you want to look at the complete project history of changes.
In the repository’s main page, the Commits tab does just that.