Reputation: 335
I've had a look around and can't seem to find an answer to this particular conundrum (which would make sense otherwise I wouldn't be here asking about it!) or at least if there has been one I haven't understood it.
I've created a project in PhpStorm, "Web server is on remote host, files are accessible by FTP/SFTP/FTPS", and I've been making changes to that with no problem. The structure of this project is as follows:
\Project Root
\
\ Subfolder A
\ Contents A
\
\ Site
\ Site stuff
\
\ Subfolder B
\ Contents B
Now, I've got this like that because although the main files I'm working on are in Site
, I occasionally need to tweak some stuff in the other subfolders.
Saving the project uploads the files without problem.
The thing I'm now having a problem with is that Site
is under version control on the server using Git. I can log on to the server and do some Git stuff there (although I'm not too familiar with Git) but when I try to pull some changes that have been committed to the repo (that's upstream, yeah?) there is a merge conflict. Because I'm so new at this, I'd rather not try to resolve the conflicts through the command line using vimdiff
.
Is there a way I can set up Git through PhpStorm to only act on that specific folder, pulling the changes from the remote repo (hosted on another server from this project), merging and resolving conflicts within PhpStorm, and then uploading the files in such a way that on the server the project shows as up to date with the current branch?
I've thought about grabbing the .git
directory from the server via SFTP and plonking that in the Site
folder like it is up there but I'm not sure that would work. I would also think PhpStorm has a good reason for not doing this in the first place.
EDIT: For a bit of clarification, Site
is dirty. I don't want to commit those changes until I'm happy with them but I still need them to be there for now. I tried stashing, pulling, then applying but that's when I get the merge conflict error, and I want to resolve these conflicts within PhpStorm.
Upvotes: 6
Views: 6089
Reputation: 335
Okay, so I figured I'd be daring and try to ignore PhpStorm refusing to touch a .git
folder. This is a long way round but here's what I did:
VCS
-> Enable Version Control Integration
Git
as the VCS for the project rootThis creates a .git
folder in your project root. Since we don't want the root under VCS but one of the subfolders, we can:
Preferences
Version Control
in the left hand paneDirectory
entry to the subfolder you want to use Git with and click OK
Apply
and OK
This will throw an error in the log moaning that the directory "is registered as a Git root, but no Git repos were found there." This is fine as we are going to add it ourselves.
.git
from the serverProject Root/Site
or whatever)You can delete the .git
folder PhpStorm created under your Project root because we don't need it anymore; it will use the one we just copied over.
There may be some extra setup to tweak. I access the Git repo with keys so you might have to add authorized keys to your git user on the repo.
You can just jump straight to Step 6 and add the directory straight there. I'm guessing it does the same thing.
But yes, now I can manage the project using Git and do my merges and things through PhpStorm instead of the command line on the server! :D
Upvotes: 5
Reputation: 38096
Since you have already stash your local changes, you can sync your local Site
with the server by below steps:
git pull
by git merge --abort
.git reset --hard origin/master
.When you are ready to use your local changes, you can use git stash pop
.
Upvotes: 0