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:
- In the repository, click on the file you want to modify (e.g. README)
- Click the Edit button
- Add your changes to it
- Add commit changes message. Example: “Adds a small message to the README”
- Create branch for it by checking: “Create a new branch for this commit and start a pull request”.
- Press Propose file change button
- In the Open a pull request page, try to be clear in your message what you’re changing and why you’re changing it.
- Use team mentions to address team members or an entire team in your message (e.g. @kdaigle-inc/developers or @omaralbeik).
- 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:
- Open the remote repository
- Code view > Copy to clipboard button to copy the repo url
- In your terminal type:
git clone <paste clipboard url>
- Enter your local repository
- Check branches
git branch * master
Only the master branch has been cloned..
- When we do a git clone, we don’t get the remote branch locally, so:
git branch --remote
- Check out new branch
-
git checkout updated-readme
- Apply changes to local repo files
- Push changes
git status git add . git commit -m "added team members" git push origin updated-readme
- On GitHub, open the pull request, you should see your commit pushed up.
- Review message: Let the team know that you reviewed the pull request by adding a message.
- 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.