Working with git branches over a remote server

Hi, I'm working on a project for my class that resides on my school's servers. We are currently using git (with remote being on bitbucket). I have been able to automatically sync files with the remote server which is great. I can also download files into my directory which is another plus. The problem that I can't seem to figure out now is how to sync with git, or even overwrite all changes to my local directory. I can't really find a good way to word this so here is an example.

  1. Branch A has files: file1.php, file2.php
  2. I work on file2.php, save, and commit on the remote server.
  3. I create file3.php and add some code to it, commit it on the remote server.
  4. I need to fix something on Branch B, so I do a git checkout branch_b on remote
  5. I sync the files from branch b to keep local up to date. However, the sync goes both ways and now file3.php from Branch A is on Branch B. Any time I save in the future, file3.php will always show up even if I don't want it to.

How can I avoid this situation and avoid overwriting code or adding files that shouldn't be on other branches to my remote server? Is there a way I can tunnel in and have PHP storm recognize I changed branches? Or is there some nuclear option so that if I say so, my local environment will be refreshed and files that aren't on the remote get deleted from my local directory?

 

0

Please sign in to leave a comment.