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
- Creating bitbucket repositor
- Integrate IntelliJ Idea with Bitbucket
- Customizing Git settings in IntelliJ
- Cloning project from github or bitbucket
- References
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
- Login to your account in bitbucket
- Go to + sign in the right up - Create a new
- Select Repository
- 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.
- Open your new repository - you can have a look in the bitcket site about the information and actions on your new repository
- Get your repository address:
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.
- Open your project in IntelliJ / Pycharm
- Main Menu
- VCS
- Enable Version Control Integration
- Select version control system:
- Git
- CVS
- Mercurial
- Subversion
- Select Git and press OK -now you will see more options in your main menu / CVS menu.
- Add remote main menu / CVS / Git / Remotes
- In git repositories - click + - adding new remote
- put the address from the bitbucket repository:
* Test ( you may need to provide password) and press OK.
-
Now you can open Version Control tab by pressing ALT+9 or View / Tools Windows / Version Control
-
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
- Once ready with file selection you can right click the Default scope and do Commit
- 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):
- 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:
- select directory
- Press clone
- Open the project
Reference
You can find more information from the official documentation of IntelliJ IDEA/PyCharm