Skip to main content
  1. Learn
  2. Software Development
  3. Guides
  4. Git tutorial
  5. How to use Git
  6. How to use pull requests in Git
GuidesSoftware DevelopmentBacklog
Git

Project and code management together.

How to use pull requests in Git

In this tutorial, you’ve learned how to use Git with Windows, Mac, or Command Line, worked with branching and tagging, and practiced managing your commit history. Now we can jump into pull requests.

Pull requests are an essential part of the collaborative development process, enabling effective code review, feedback, and seamless integration of changes into the codebase. In this step-by-step tutorial, we will guide you through the ins and outs of pull requests in Git. You will learn how to create a pull request, collaborate with team members through discussions and feedback, and ensure the smooth merging of your pull requests. Through step-by-step instructions and hands-on examples, you will gain practical experience in utilizing pull requests for successful code collaboration.

To learn more about pull requests, you can revisit our introduction to pull requests.

To demonstrate how to use pull requests, we first need to create, modify, and push a new branch.

If you missed our introduction to pull requests, you can .

To start, create the following JS file in the repository.

// sort.js
  var number = [19, 3, 81, 1, 24, 21];
  console.log(number);

Then push it to a remote branch.

Learn how to push to a remote repository on Windows, Mac, or Command Line

Next, create a branch called “add-sort-func” to sort an array.

$ git checkout -b add-sort-func

Learn how to create a branch.

And modify the file as follows.

// sort.js
  var sortNumber = function (number) {
    number.sort(function (a, b) {
      if (a == b) {
        return 0;
      }
      return a < b ? -1 : 1;
    });
  };

  var number = [19, 3, 81, 1, 24, 21];
  sortNumber(number);
  console.log(number);

Then commit the changes.

$ git add sort.js
$ git commit -m "<commit_message>"

Finally, use the git push command to push the modified branch to a remote branch.

$ git push origin add-sort-func

Now you’re ready to create a pull request.

In case you missed our intro, we’re using Backlog in this tutorial, but especially in this section where we highlight pull requests. You can start a free trial of Backlog now.

Subscribe to our newsletter

Learn with Nulab to bring your best ideas to life