DEV Community

Cover image for Tips for configuring GitHub in IntelliJ
Victor Macarios
Victor Macarios

Posted on

Tips for configuring GitHub in IntelliJ

The steps described in this post were done using IntelliJ IDEA CE 2019.3 and macOS High Sierra (10.13.6).

When setting up GitHub in IntelliJ we have to follow some tricky steps.
I'll show the ones that I have passed by.

The first step is to configure the GitHub account.
To do that, just click in Configure link on IntelliJ Welcome Screen and then in Preferences option.
IntelliJ Welcome Screen

Open Version Control section and then GitHub.
Click in the + button and add the credentials.
If you want to use SSH (by the way, that is recommended for security reasons), you should tick "Clone git repositories using ssh" and click OK.
Verson Control Settings


(Here comes the first trick)
If you don't have added the SSH key for your computer on the GitHub website, you'll not be able to use this option.

Let's see how to add it then:

  1. Open the Terminal app
  2. Enter the following line:

    ssh-keygen -t rsa
  3. Press ENTER key to accept the default location to save the files

  4. Create a password for your keys (you'll need to type it twice)

    Your keys are now saved in .ssh folder inside your home folder.

  5. To copy it, use the command below:

    pbcopy < ~/.ssh/
  6. Now, access the GitHub website, click in your avatar picture (top-right) and then Settings option.

  7. Click in SSH and GPG key then in the green button named New SSH key.

  8. Type a name that identifies your computer, pastes the key and finish by clicking in the Add SSH key button.

  9. Your GitHub password will be requested.

    GitHub SSH Settings

With the SSH key added to the GitHub website, you can now clone a repository by using the Get from Version Control option in Welcome to IntelliJ IDEA screen.

Now that your repository was copied locally, you can commit using VCS>Commit (⌘ + K) option on the menu and push by using VCS>Git>Push (⌘ + ⇧ + K).

And here comes another trick.
For security reasons, GitHub has two options in Email settings that helps protect your privacy (Keep my email addresses private and Block command line pushes that expose my email).
If those options are ticked, maybe you receive an error when you try to push your commits.
GitHub Email Settings

Unfortunately, the error notification doesn't always have enough information.
Using the menu View>Tool Windows>Version Control (⌘ + 9), you can see more detailed information at the Log tab.
You should probably see the below message:
Your push would publish a private email address.

So, how can I push my commits while keeping my privacy?
GitHub provides us an email to avoid exposes our private email.

Let's see the steps to get it and solve the issue:

  1. Access your GitHub Settings>E-mail and you will see the provided email at the first line of the Keep my email addresses private section (highlighted in the image above)
  2. Copy it to the clipboard
  3. Open the Terminal app
  4. Navigate to your local repository directory
  5. Type the text below (replacing the content between the quotation marks with your email copied in step 2):

    git config --global "{ID}+{username}"
  6. Reset the author information:

    git commit --amend --reset-author
  7. Return to IntelliJ and now you can push by pressing ⌘ + ⇧ + K

Now you've finished the IntelliJ/GitHub setup and can start to code.

Happy coding!
Victor Macarios


Top comments (0)