How to deploy lots of changed files to remote server after testing on local server.

hi!

I'm running Debian with Apache/PHP/Postgres on local virtual host on Windows (I'm using Sun VM VirtualBox) as a test server. Each test websites are accessible via some domain and a little configuration in hosts file. Debian's /home/ directory is shared via samba and is mounted as W: drive on my Vista.

Now: I created a project using the mounted drive, so each time I save files (with no auto-deploy), changes are instantly visible on my browser on test domain.

Suppose I change lots o files, test them locally on my virtual-linux and after acceptance (from me or my client), I'd like to publish all changed files to my production server. Question is: how? How can I select files, that were changed? Can I put files, that I work on, on some list to deploy the files later? I can't remember all files that were changed, so it's impossible to select them all after acceptance and hit "Deploy to ...". How can it be done? Automatically or by some list...? I'm looking forward for local-remote synchronization, but until then I have to sync my project between local and remote server.

Please help.

17 comments
Comment actions Permalink

The way i do it is with change lists and git.

When i have a section that i know will need to go up to the production server but needs to be developed on the local server i first make sure that the CHANGE panel in phpstorm is empty. (or make a special change list for just this thing.)

Then do all my programming.

Once im ready to upload it to the production server I open the CHANGES panel and there is a list of all the files that have changed.

Right click on the change list and do "upload to myserver.com"  or "upload to.... " and select a server.

There is also the option of "Upload on commit"  so that when you commit to git that the files will get uploaded but I tend to stay away from that for now becasue if the upload fails, the commit still gets done and your changes list dissappears.

There is a feature request for upload/download from the git changes panel, but its still not implemented yet.  So untl it is, its best to upload, and once you see the upload was successful, THEN commit to git.

0
Comment actions Permalink

Thanks Michael,

what you wrote is what I wanted to do for whole day long yesterday... But with no success with Git.

I don't know how to make VCS with Git working in PhpStorm. I installed Git and tried to configure all the stuff as pointed here: http://www.jetbrains.com/phpstorm/webhelp/using-git-integration.html, but with no success...
Git is installed, Git option in VC menu exists, but I don't know how to bite it... Is there a good tutorial how to configure and use from scratch? PhpStorm's help is not clear for me, as it is not step by step... I don't know where the repository folder should be located (put it in the project root), I couldn't add any files do Git list... I didn't manage to do starting point (some HEAD issues...), with all files in their current state tu push to production server (as the local files already differ from remote ones). Everything about Git is totally new for me yet, so all the configuration and working process is completely chaotic... I don't want to use GitHub, and there are some configuration fields asking for server and user, while I have my Git installation on my local terminal...

Could somebody show me (me and others, who didn't manage to run Git) how to install and run Git in PhpStorm step by step? I need it to be told as to a cow in a row...

Thanks a lot in advance for somebody's patience an effort.

0
Comment actions Permalink

Hi Adam,

Yeah its not a big deal.  There are tons of other features that im sure git can do, but for me i dont use them.

I dont use github
I dont ever Push or Pull.
and i only stated using git because of phpstorm, so im pretty new to it too. But it is easy once you get it set up.

What i do is this:
#1 open the command line to the folder of my new project.  say for this exercise (/PhpStorm_projects/junk)

In my /junk/ directory i do:
[CODE]
git init
git add .
git commit
[/CODE]

then go back into phpstorm and do
VERSION CONTROL -> (something like activate version control)->GIT

then right click on the main folder in my PROJECTS pane.
in the drop down menu now there should be a GIT item, which opens up to GIT->ADD.

Do that for your project and you will get a new item in the bottom of the IDE called CHANGES.

The first time you open it it will have a "default" changelist.  which after you do GIT->COMMIT CHANGES.... it should make everything in that changelist dissappear. (they have all gone INTO  version control so there are no outstanding changes.)

Everytime from now on when you change something it will appear in the CHANGES panel until yo do a GIT->COMMIT CHANGES...

see if that works.

0
Comment actions Permalink

Yeah, using local git repository is the easiest and cheapest way to get a versioning, history and usable changelists for a project, especially when working alone.

And you don't even have to use commandline. (However to create initial repo commandline IS faster)

To init repo on any project use Version control/Import into version control/Create git repository and click ok couple of times. (== git init)
All your files will go into "unversioned" on Changes panel. Invoke "Add to repository" from context menu for project root folder. They will go into one huge "Default" changelist. (==git add .)
Then just commit it. I usually use a comment like "initial" and put a small project description there. (==git commit)

After that you can use changelists, history, git log view etc.

Couple of advices:

Always add long meaningful comments to all your commits. Even if working alone. Put a ticket number there if you fixing an issue from tracker or support request.
Keep the repo with the project in your archive, do not erase it. The historical info it provides becomes valuable with each minute :)
"Annotate" feature is particulary useful later in maintenance to investigate old changes.


You can learn more advanced stuff later *if* you need it.
0
Comment actions Permalink

OK, guys!

Thanks for you replies. I tried do set Git both ways, but it's still not working.

First method was Michael's: I entered what you said, but all I've got is:

T:\>git init

Reinitialized existing Git repository in T:/tonery360/.git/

T:\>
T:\>git add .
error: unable to write sha1 filename .git/objects/89/67278db67cc9fd084dcffc1768c
49729f8721f: Permission denied


error: .htaccess: failed to insert into database
error: unable to index file .htaccess
fatal: adding files failed


I've found, that the Permission denied error can be avoid by using git's config option:


git config --add core.sharedRepository group


But it does not help... On my local VirtualBox's Debian, there is a Samba with www-data user and group is forced, and 777 mode for files and directories is set. Repository's folder is mounted on my windows as a shared drive from Samba, all files and dirs are rwxrwxrwx www-data.www-data (even file structure created by git init. Everything works fine, except git add . ...

What do I do wrong? :\


Next method is Alexey's:
Everything seems to be fine, except that there is no "Add to repository" in project's context menu... (the same is to Michael: there is no "GIT -> ADD" option in project's menu...

I created a new Changelist, made it active. I changed some file, and saved it. In my Version Control Console I have:

22:00:37.535: cd T:\
22:00:37.545: git log --max-count=15 --all --name-status --pretty=format:%x01%h%x02%H%x02%ct%x02%an%x02%at%x02%ae%x02%cn%x02%ce%x02%p%x02%d%x02%s%x02%b%x03 --encoding=UTF-8 --full-history --sparse -- .
fatal: bad default revision 'HEAD'


And I'm still stuck... Can't go any further with my job, because I cannot control what was changed in my current project to sync it witch production version...  :(

Help is needed so much here... :|

Thanks again.

0
Comment actions Permalink

this looks suspicious to me:
T:\>

It looks like you are in the root directory of the system, not in root directory of your project.

for me i keep all my projects in
/home/me/PhpStorm_project/the_project_name1
/home/me/PhpStorm_project/the_project_name2
/home/me/PhpStorm_project/the_project_name3
/home/me/PhpStorm_project/the_project_name4
etc...

so when i want to initialize it from git, i need to go into the project directory before doing the commit.

so for me from home:
cd ./PhpStorm_project/the_project_name1

then do the
git init
git add .
git commit

if you have the CHANGES panel, when you right click on a change list is there a GIT menu section?  If there isnt, then my guess is that git isnt turned on in the VERSION CONTROL->use version control system->GIT.  or that another version control system is firing when you do that log.  Not sure about that one since you obviously have some version control running.

I have added a screenshot of my CHANGES panel.  on the LOCAL tab.  when i choose  COMMIT CHANGES from the LOCAL tab the change list dissappears and goes to the LOG tab.



Attachment(s):
changes_panel.png
0
Comment actions Permalink

Thanks Michael for your efforts. :)

The  T:\> folder is a root for my project (this is the drive mounted from  my Samba; the project is right there in the root of this drive). So i  think that this should be no problem.
But I made some testing, and  mapped another drive, but this time the drive was mounted in /home/, so  my "T:\" project became T:\projectName\. Unfortunately I still have got  the same issue with git...

According to Changes panel -  I don't have the Git option... And I don't know what I'm missing. There  are few screen shots attached, so you could se what I see. Perhaps  there is something to do yet.



Attachment(s):
git-changes-panel-changelist-context-menu.png
git-project-context-menu.png
git-settings-version-control-vcss-git.png
git-settings-version-control.png
git-version-control-menu.png
0
Comment actions Permalink

from that first screenshot, it looks like git is working.

if you made a change to a file i would expect to see it in TEST1 (1 files)

Then clicking on COMMIT CHANGES would bring TEST1 back to (no files) again.

Im not a git expert, sorry.  Hopefully Alexey will be able to help further.

-- edit --
But i would also guess that you havnt got any server paths mapped because there is no "Upload to myserver.com" option in the first screenshot either. thats under TOOLS->DEPLOYMENT->CONFIGURATION->MAPPINGS

0
Comment actions Permalink


After editting some file, nothing has changed in the Changes panel. After I saved file there was "updating" for a moment , but nothing has changed.

I have one remote mapping set up. So there should be some "Upload" option. See the picutre here: git-project-context-menu.png - there is "Upload to" option.

It's a little bit strange, that git isn't working with this project. I created a new one project (new commission), and I found, that Git seems to be working a little bit better: in Changes panel there is a [+] icon, to expand the "Unversioned Files" list. But still there is no "Add to repository" in context menu for project root folder. I found Git -> Add option in Changes panel, when right-clicked on "Unversioned Files. But after that I get the "unable to write sha1 filename .git/objects/ef/...: Permission denied" - although I have all permissions set and the git config --add core.sharedRepository group was invoked in project's root directory...

I'm stuck... :(

If I only knew, what I did wrong, I'd install everything from the begining. Perhaps I try to install all the stuff once again on some wirtual machine, to make it all clean and clear - perhaps I did something wrong by the way...
I need to make it working as there is no other option to synchronize local and remote copy of a project in PhpStorm...

Thanks for help.

0
Comment actions Permalink

Are you working directly over mapped shared network folder and creating git repo inside?...
Are there any other devs using same folder?....

0
Comment actions Permalink

Are you working directly over mapped shared network folder and creating git repo inside?...


     Yes, this is how I do it. But this is only a testing site - production server is remote, in different location, on separate machine.

Are there any other devs using same folder?....

     No, I am the only one in this project.


     Does it help anything? :)

0
Comment actions Permalink

Try using just command line first to see if Git is functioning.

Use the command git status in your project directory and see if it returns a message.
If you have any changes it should.

If you have changes, git add .       < include the dot
then
git commit -m "Your commit message"

Then git status should return something like nothing to commit (working directory clean)

After that you know git is working, move to phpStorm and configure Git for the project if it hasn't been setup already.

0
Comment actions Permalink

hmm... I already tried that, and this is what I get:

T:\tonery360>git status


# On branch master


#
# Initial commit
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       .htaccess
#       .idea/
#       a/
#       clearbasket.php
[...]
#       zestawienie.php

nothing added to commit but untracked files present (use "git add" to track)

Then I do add command and I get:

T:\tonery360>git add .


error: unable to write sha1 filename .git/objects/89/67278db67cc9fd084dcffc1768c


49729f8721f: Permission denied

error: .htaccess: failed to insert into database


error: unable to index file .htaccess


fatal: adding files failed


So I'm still in the same place... I know about the git's core.sharedRepository group option, but it does not help anything. All rights of files and directories are OK (full rwx), but nothing can be added.

How can I remove all the git settings from my project? I think I'm going to clear everything: unistall git, clear git's setting from my project etc. Something is wrong, and I don't know what... :\

Any ideas?

0
Comment actions Permalink

You have a permission issue with your .git directory.
Make sure what ever system that .git directory is on that you have full permissions for it.

0
Comment actions Permalink

...and there is full permission (full rwx), as I mentioned in my last post...

0
Comment actions Permalink

Sorry, this errors mean that you have issues with your OS/sharing setup/Git installation/something else that are well beyond of our coverage.
You should try any GUI tools including our IDE only after you have the commandline properly working.

0
Comment actions Permalink

OK, I finally got it!

I made a huge research about the git's "permission denied" problem. And finally I found a solution - I upgraded my Samba from stable Lenny version to 3.5.11. Now everything seems to be OK, when running git add . command.
After running PhpStorm in Changes panel I can see all files at their current state in my chagelist. I can create new changelists and then commit them. Now I got it, how I can deploy lots of changed files to remote server (and lots more, which I will learn in near future).

So thank you all very much for your kind help. :)


But now, after trying to use it, I have a little consternation: is there any way, that I can add a file manually to changelist, without opening and editting it (e.g. image files and files to be forced to add to the current revision and again deployed to remote server)?

0

Please sign in to leave a comment.