How to work with git worktree in PhpStorm and see the result in a browser?

158 views Asked by At

I have a simple project/var/www/testy.local with one file index.php that contains: <?php echo 111;.

Apache settings is pretty standard:

<VirtualHost *:80>
   ServerName testy.local
   DocumentRoot /var/www/testy.local
</VirtualHost>  

Result: in a browser with URL http://testy.local I see the result: 111


Now

  • I create two git branches: git branch b1, git branch b2
  • I create two worktrees: git worktree add worktree/b1 b1, git worktree add worktree/b2 b2
  • I make changes in every index.php of these worktrees

Question 1: now, how do I see the result of my changes in the browser? I made changes in wortree/b1 and I want to see it, to make sure that I did it right and nothing is broken. Apache points at the root of app, not at the switched worktree.

Question 2: How do I work with worktrees in the PhpStorm? How to switch between worktrees to see changed files in the "Commit" tab? What should I do to see branch b1 in "branches corner" and how do I commit to the branch currently pointed to by worktree?

It doesn't suit me to type manually in the terminal commands cd worktree/b1, git commit etc

enter image description here

0

There are 0 answers