Search code examples
phpgitphpstormbitbucketatlassian-sourcetree

Setup PHP project using PhpStorm, Git, SourceTree, Bitbucket


I am trying to stick this all pieces together, so I have:

Remote:

  1. Dev server, where Http Server + DB + my site - folder, where all files of my future project will be.
  2. Bitbucket account

Locally installed:

  1. PhpStorm
  2. Git
  3. SourceTree

What would be a queue of actions to setup all this stuff to make them work together in right way?

Problems I faced:

  1. If I first create PHP project then I can't clone repository from Bitbucket to not empty folder.

    How to tie existing project to newly created repository of Bitbucket? Because usually project starts with creating some skeleton from git, so I can't start with empty project folder...

  2. Imagine I make changes, save it to remote server, check it works, then commit it to Bitbucket then I realize I need back to code which was few commits before.

    How could I roll back my project code? And then how will I update this on a remote server? Do I need delete all files and upload them again from project?


Solution

  • Problem 1:

    Normaly you start with a local project and push it to the remote but it works also the other way round, checkout the remote repo to your computer and then copy the project files into that folder, then use SourceTree to commit and push them.

    Problem 2:

    You don't rollout commits, you rollout tags and branches. Best is you start with a master branch where you have everything that works 100% and when you develop and work locally you have a second branch develop for testing. When your tests and stuff in develop branch work, you merge it into the master branch. If you want to go a step further, try git-flow.