Bitbucket and IntelliJ git integration was one of the reasons to move from eclipse to IntelliJ Idea/PyCharm. Working with eclipse and eGit I was facing many problems and sometimes my code was lost.

In IntelliJ integrating , cloning and working with Bitbucket is really easy and reliable. So far I haven't face any problem or code mess ( now I'm using Intellij as a primary IDE for more than a year).

In this post:

Integrating Intellij project and Bitbucket repository

In order to use bitbucket you will need to register and create a repository(bitbucket offers private repositories for free - this is the reason why I prefer them in comparison to github). Once you have created account you can create your first repository from the site interface by:

Creating bitbucket repository

  1. Login to your account in bitbucket
  2. Go to + sign in the right up - Create a new
  3. Select Repository
  4. Enter
    • Repository name - try to use descriptive name for your project
    • Version control system - GIT or Merucurial
    • Access Level - this is a private repository - I prefer working to private repositories on some of my projects.
  5. Open your new repository - you can have a look in the bitcket site about the information and actions on your new repository
  6. Get your repository address:

https://[email protected]/yourusername/projectName.git

that's it.

Integrate IntelliJ Idea with Bitbucket

Now we are going to integrate our project with Bitbucket (have in mind that the same apply also for git or any other version control system).

You can create new empty project or use an existing project with code inside which to be pushed to the empty repository.

  1. Open your project in IntelliJ / Pycharm
  2. Main Menu
  3. VCS
  4. Enable Version Control Integration
  5. Select version control system:
    • Git
    • CVS
    • Mercurial
    • Subversion
  6. Select Git and press OK -now you will see more options in your main menu / CVS menu.
  7. Add remote main menu / CVS / Git / Remotes
  8. In git repositories - click + - adding new remote
    • put the address from the bitbucket repository:

https://[email protected]/yourusername/projectName.git

* Test ( you may need to provide password) and press OK.
  1. Now you can open Version Control tab by pressing ALT+9 or View / Tools Windows / Version Control

  2. Select Unversioned Files

  • Add to VCS - this will add the file to the repository and this file can be commited and pushed later
  • ignore - this file will not be tracked for versioning control
  • delete - remove the file from the project and file system
  1. Once ready with file selection you can right click the Default scope and do Commit
  2. Finally you can push the changes to your repository.

Customizing Git settings in IntelliJ

Sometimes you will need to use custom settings for your git configuration. You can change the user, profile, git executable path. Customization can be done from:

  • Main Menu
  • File
  • Settings or CTRL+ALT+S
  • Version Control - you can see the current project settings
  • Git - git executable path

Cloning project from github or bitbucket

If you want to clone existing project from bitbucket or github you can clone the project. The straightforward way to clone github or bitbucket in IntelliJ or PyCharm is by following next steps:

In case of no project

  • Check out from Version Control
  • Select Git
  • paste the URL and test(if you have rights to read the repository):

https://[email protected]/yourusername/projectName.git

  • select directory
  • Press clone
  • Open the newly created project

If you are in open project

  • File
  • New
  • Project from version control
  • Git
  • paste the URL and test:

https://[email protected]/yourusername/projectName.git

  • select directory
  • Press clone
  • Open the project

Reference

You can find more information from the official documentation of IntelliJ IDEA/PyCharm