Avoiding external changes into local during deploy

Due to the way the project was originally set up, we're unable to test local copies on our computers, so we have to copy over our changes to the dev server to test. However, using PHPStorm's deploy (which has been much more useful than other editor's), it can bring in changes from dev to the local files that you don't want to be there (which can end up being inadvertently committed or cause extra work reverting them) without it even warning you first, requiring us to right-click the open file then Deployment > Compare to keep the dev changes out.

Is there a setting somewhere (I haven't found it yet) that will keep these dev changes out and only try to move/merge over local changes? We can work out merge conflicts no problem.


Hello, please check Settings(Preferences) > Build, Execution, Deployment > Deployment > Options> "Warn when uploading over newer file". There are few options available for this: 

- Compares the sizes of the local and remote files

- Compares the remote file timestamp

Please see more here, it's pretty well explained and it looks like what you need.


Yes, we have "Warn" set (see screenshot), and it only warns if newer file has changed by showing a yellow bar at the top (which is great), and only stops me when there's a merge conflict, but if there's changes along different lines for the two files, it will just merge them without showing me the compare, and I don't need timestamp or file size change compare, just line/character change compare (since we only edit text files).



Just to confirm: this is about bringing changes from a remote deployment server to a local machine, correct?


No, the issue is with deploying from local to remote. I didn't think deploy meant the other way.


Apologies, I'm probably missing something but I can't see how "Deployment > Upload to..." could overwrite your local changes. Could you please give us an example?


"Notify about remote changes" seems to be working Ok:


My original post mentioned "[deploy] can bring in changes from dev to the local files that you don't want to be there", and if you're now saying it doesn't do that, I don't know why you didn't mention that in your original reply.

All I noticed was it shows the merge compare window when the same lines in both locations are changed, and I simply assumed "Merge" (which shows in the top yellow bar) without compare meant it merged them on both local and remote.

I don't see this "Merge and upload" button pop-up, but I'm using v10 (I've explained why we're not going to reinstall the latest *major* version every 3 months), but I assume the behavior is the same.

Now that I think about it, I did notice it will show the compare window if there is only a change on the right (dev), which lets me save to the left (local), so as long as it will show the compare window when dev has changed outside of my editor, I'm fine with that.


I just clicked "Merge" on the "external file is different" (paraphrase) message and it overwrote my local file without popping up the merge window; this was the exact problem I thought I was having before. I don't want external changes to automatically overwrite local file, I needed this file to have my changes merged with externals but it overwrote my changes with the server's version which was just an older copy.

The only way I can get the file over now is to modify the file (like add a space) then Ctrl+S deploy, or right-click > Deploy. I expect Merge to let me choose what gets merged so PHPStorm doesn't overwrite my new local changes with an older copy on the deployment server.


I'll test out the same and will let you know what we can do about it.


Not sure if you tested anything, but we're still running into the problem of merging local/external changes during a deploy and the external changes saving locally. We're trying to avoid the external changes from saving locally.

Any setting or solution to this? What happens is we have to delete the external changes from our local copy (which can be cumbersome) or we can end up committing external changes from another developer onto the wrong branch.


Sorry for a delay, I was just unable to reproduce this.

Could you please test the same with another project? Would a merge window appear in a before mentioned scenario in a fresh project?


Why would another project be different? Because of a setting? Which setting controls this?

We only have one project for this scenario.

The merge prompt has always appeared if an external file was changed (by another developer or by a git change) before a deploy, nothing has behaved any differently that I know of, we just noticed again that external changes were saved locally and I don't know how it's supposed to work or what controls this behavior. I'm not seeing any settings about it.


I found one anomaly that avoiding would help alleviate this problem (external changes saving locally).

In the Version Control tab, it says files I didn't edit were edited (they don't show in git status). I don't know why this is the case.

How do I correct that problem? My deployment options are set to only compare content, not date or anything like that, but PHPStorm appears to be checking date on the local file compared to something else... not sure what. It shouldn't show any different files than git status.


If I right-click the file in question, then Show Diff, it says Contents are identical. How is this possible? How do I remove this from the Version Control > Local Changes list so it doesn't try to keep uploading when I deploy?


This is still happening; another developer made a change to a file, the file was then stashed on dev, the branch updated, then the other developer's changes unstashed, then in PHPStorm I made a change on another line, got the merge conflict prompt for the lines that came down from git (which were both empty on both my local and the dev file but filled in the middle file, not sure why), so I chose my side for some and dev for others to see what it would do since they both reported the same change (deleting the line), then clicked the double-left arrow for the other developer's change to go into the middle (my local copy didn't have it), then saved and uploaded.

ALL changes were saved to BOTH local AND dev, so I had to delete the other developer's change locally (which shows as a diff in my git), but then if I changed the file anywhere else, uploading just overwrote his change so if he tests without checking every line of all of his files for differences, his testing will not go as expected and it may take him a long time to figure out why if I don't tell him (this happened before to me from another developer who didn't realize the problem).

What am I supposed to do? You guys are saying the dev changes should NOT save locally, but they are! Which version of PHPStorm did you test my problem? We're using the paid versions of PHPStorm between version 9 and 10, we ran into a lot of problems upgrading a major version from 8 and now you're requiring us to do it every 3 or 4 months to keep up with yours, which can take hours of our time each time due to settings not importing correctly, and we run multiple complex projects.

I wonder if you are not testing as I described or are not understanding the problem exactly.


By the way, this should only ask to solve merge conflicts for the same lines that are edited differently on both sides, which was not true in any case here, it made me choose lines that were only edited on one side; these lines should simply stay on dev and not delete if I don't choose to click double-left-arrow to the middle, and not copy to local either.

Lines that are not conflicting should not provide a choice in a merge conflict prompt!



Latest EAP build brings some changes into this workflow. Now you'll be able to preview the changes on a middle preview pane. 

Here some picture to illustrate this:

1) initial merge conflict, local file on a left side, deployed on a right:

2) I've merged changes from a right side (using double arrow left icon):

3) I've merged changes from a left side:

So now it should be more obvious as what is going on during the merge. Next time you face the issue we would really appreciate some screenshots illustrating it.




What is "Latest EAP build"? We're on PHPStorm 10, so do we need to upgrade to the latest "major" version or are there minor versions we can update that won't require us exporting/importing our settings and losing half of them like last time from 8 to 10?

1) The problem doesn't just manifest on merge conflicts (unless PHPStorm is considering different lines changed as a "conflict", which it shouldn't), it manifests also if there is just one line changed on each side completely separate from each other (the middle Result is saved to both Local and Deployed, when we only want it saved to Deployed).

So the screenshots aren't explaining anything more than I already know; the problem is that changes from Deployed are saving to Local when we don't want that and you're saying that shouldn't happen. We have multiple different scenarios (depending on changes) and most of the time the result is undesirably saving Deployed changes to Local (which results in another developer's test changes on Deployed for his branch showing up in someone else's git diff for their own branch on Local).


So we've always had the middle window, but the issue has always been that the middle window saves to both local and dev, when we only want our local changes merged into the dev side (not the dev changes merged into our local side).

The reason for this is that we don't want other developer's testing changes showing up in our local git diffs; unfortunately we're unable to test a local copy of the website, we have to copy our changes to a dev box, and PHPStorm is causing us to have to keep erasing other developer's code from our local files if this window pops up.

Also I'm not sure what causes the window to pop up if only one side has changes. For instance: I checked out a branch locally, PHPStorm recognized which files were changed (from the checkout), compared them to the dev files (I have it set to compare content), and it brought up certain files that were only modified on dev's working copy by another developer (not by me locally), so it showed no changes on the left, and changes on the right with the less-than arrow (<) and X; if I clicked <, the changes from dev copied locally; if I clicked X, the other developer's changes were deleted on dev. This is counter-productive and causes us to either delete other developer's dev changes locally or we have to test our changes completely separately (so we just would click Overwrite instead, causing a lot more time than it should.


Please sign in to leave a comment.