How To Create A Pull Request From Intellij In 6 Easy Steps

Maddy - Mar 21 '22 - - Dev Community

Are you wondering how to open a pull request on Github from Intellij?

This tutorial is for you.

Let's start.

CLONE THE GITHUB PROJECT

Use the command below to download the project on your local machine.

git clone git@github.com:MaddyGre/your-first-pr.git
Enter fullscreen mode Exit fullscreen mode

Then, import the project on Intellij.

CREATE A NEW BRANCH

Let's create a new branch. To do this: use the following command.

git checkout -b First_Branch
Enter fullscreen mode Exit fullscreen mode

You can do this via the IntelliJ terminal.

First_Branch.png

The -b allows you to:

  • Create a new branch (whose name is First_Branch)
  • Move from the main branch (the default branch) to the newly created branch.

You can see in which branch you're currently at the bottom of IntelliJ.

Main_Branch.png

Once you hit enter, the branch name will change.

First_Branch_created.png

CREATE A NEW FOLDER

Once you import the project, create a folder called "PullRequest".

Inside this folder, create a simple class called Main.

MainClass.png

In this class, create a main method where we're simply going to print out.

Congratulations! You've now learned how to open a pull request.
Enter fullscreen mode Exit fullscreen mode

FANTASTIC! We have a new branch, and we are ready to open a pull request.

CREATE A COMMIT AND PUSH

You should see a tab called "Commit" on the top left. In this tab, you'll see all the changes you've made.

Select the files you want to move to the remote repository (in my case, I chose to push all of them).

Then, add a commit message in the text box.

CommiMessage.png

There are two ways to push the changes remotely:

  1. By pressing the Commit and Push button.

  2. Entering Commit and later Push to move your changes remotely.

You can decide to do it either way.

I use the Commit and Push button most of the time as it's quicker.

CREATE A PULL REQUEST

Now, let's go back to Github.

You should see something like this:

PR-Github.png

Click on the Compare & pull request button.

You should see a panel like this:

OpenPullRequest.png

The branch First_Branch will be merged to the main branch.

If you've noticed, the "Create pull request" button has an arrow that will present you with the option of creating a draft pull request.

CreateDraftPullRequest.png

It's ideal for opening a draft pull request when you don't want your teammates to review it yet because you have some minor changes to make.

For now, let's stick with a fully finished pull request.

Go ahead and press the Create pull request.

MERGE A PULL REQUEST

After you press the button, you should see this on Github:

PROpened.png

In the real world, your pull request will undergo a code review by 1/2 colleagues before you can press the merge button.

In addition, your pull request will go through some checks (for example, code smells, code analysis, etc.) before the "Merge pull request" appears.

Since this is a simple tutorial, you can merge the pull request.

This is what you should see once you merge the pull request.

merged.png

Once you merge a pull request, you cannot go back and change it.

You might be wondering:

What if I have to make some further changes?

You go back to STEP1.

Why is it important to know what a pull request is?

A pull request is how you communicate to your teammates that you have made changes that you would love to move remotely.

As a software engineer, you will open pull requests almost weekly.

I hope you've found this article helpful.

Please let me know any problems you might have while opening a pull request.

Until next time! 🙋🏾‍♀️

ADDITIONAL RESOURCES

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player