Let me show you how can you setup your bitbucket with PhpStorm to take full out of PhpStorm on windows.
- Install PhpStorm and Git. You can get appropriate Git download from here.
- Make sure that the git is in environment variables by using command prompt. If not, add paths in environment variables according to installation location of git, such as given below.
C:\Program Files\Git\bin C:\Program Files\Git\cmd
- Create a repository on bitbucket.
- Create a project (new or existing) on PhpStorm and open the terminal in PhpStorm. You can open the terminal in PhpStorm by View >> Tool Windows >> Terminal. There is also a shortcut key to open the terminal by default in PhpStorm and that is Alt+F12.
- Make sure you are in the project directory. PhpStorm will keep you in project directory by default.
- Perform following commands to set up a repository and attach it to your Bitbucket repository. Please, replace “your-username” and “repository-name” with accurate information in the following commands.
git init git config --global user.email "[email protected]" git config --global user.name "Your Name" git add . git commit -m "Useful message about the commit" git remote add origin [email protected]:your-username/repository-name.git git remote set-url origin https://[email protected]/your-username/repository-name.git git push -u origin master
It will set up your repository and you are almost done.
Go to next step 7 if all went well but if you are getting an error similar to following:
error: failed to push some refs to 'https://[email protected]/your-username/repository-name.git' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing
The message is clear. There is something in remote repository that is not in the local repository.
Bring the content of remote branch and add it to the local branch. The following command will take care of this.
git pull origin master git push origin master
There is also another way to force push. But that is out of scope for the current tutorial.
- Now, every time you will make some new changes and want to commit it to bitbucket, you will be using the following command.
git add . git commit -m "Useful message about commit" git push -u origin master
If you want to be able to load project from bitbucket, directly into your phpstorm, download and install the latest connector for phpstorm from https://bitbucket.org/dmitry_cherkas/jetbrains-bitbucket-connector/downloads