CHAPTER 4 · 1 lesson · 13 exercises

Pull Requests and Code Review

Push branches, open pull requests, review code, address feedback, and merge.

0 / 13 solved

This chapter covers the industry standard of never pushing directly to main.

You push your branch, open a pull request (PR) asking the team to review and merge your changes, and merge only after approval.

Here is the most fundamental distinction:

A pull request is not a built-in Git CLI command. It is a collaboration feature built on top of Git by platforms like GitHub.

That is why pull requests are managed through the remote view tabs (GitHub UI) on this screen.

The complete workflow looks like this:

1. Check or open an Issue describing the task
2. Create a feature branch, work on it, and commit
3. Run git push to upload the branch to the remote
4. Open a pull request (PR) on GitHub
5. Reviewers check the code, leave comments, and approve (LGTM)
6. If fixes are requested, edit files, commit, and push again to update the PR
7. Merge the pull request into main
8. Run git pull locally to bring your local main up to date

Remember step 8! When a PR is merged on GitHub, your local repository does NOT update automatically.

Lessons in this chapter

Pull Requests

  1. 04Pull requests (PR) and code reviewPush your branch, open a pull request (PR), receive code reviews, and pull the newly merged commits into your local main branch.Go to the exercises

Next up is “Undoing Changes and Resetting”. Discard uncommitted edits with restore, unstage changes, and undo commits with reset and revert.