Location of .git folder

Hi
Is it necessary for the .git folder to be in the same folder group as the files it is tracking or can it be in a remote folder? I'd like to put it in my project settings folder but when I try that I can't get it to track the files in the web folder.

e.g. I have a project folder containing the .idea folder. I create the git repository here so I get a .git folder too. This puts my 'Project' under git and the files there turn brown.
In Project Settings | Version Control I set my *web* folder to be under Git. This all looks plausible and correct but my web folder resolutely stays untracked.

Yet if I create the repository in my web folder it tracks my web files, though not the Project files. It's as if the git function can't traverse to a different folder tree. Is this right?

Now I come to think about it, why do I even have to fill in that Project Settings | Version Control dialog? Is that just to inform PS so that it knows to ask if I want to add a file to git?

Thanks for any pointers!

11 comments
Comment actions Permalink

I no git expert, but usually .git is only at the very top of my projects, so right next to the .idea folder.

Then if i want to only add a couple of lower folders into git, then i add just those folders to git. (but i usually add everything coz its easier.)

In my .gitignore file (which is also on the same level as the .idea folder and .git folder)  i put into it.

.idea/
.idea/workspace.xml

so that those files dont end up in git.

0
Comment actions Permalink

Thanks for the reply. I can't help thinking though that it should be possible to put the .git folder anywhere, allowing the working directory to be kept clean of such "helper" files. Hopefully a passing expert might be able to shed some light...

0
Comment actions Permalink

if your usual setup is to map your public_html directory on the server to the root path of your project, you could always go one step back and bring your public_html directory into a sub-directory of your project.  This way the .git folder would be outside of your working files.


eg:
Usually i set my projects up to where:
http://the-web-site.com

maps to
/PhpStorm_projects/the-web-site.com

and inside
/PhpStorm_projects/the-web-site.com/index.php
/PhpStorm_projects/the-web-site.com/other_file.php
/PhpStorm_projects/the-web-site.com/something_else.php
/PhpStorm_projects/the-web-site.com/.git
/PhpStorm_projects/the-web-site.com/.idea
/PhpStorm_projects/the-web-site.com/.gitignore
etc...

but if you added one level directory of buffering you could keep .git outside any files that were actually on the server.
/PhpStorm_projects/the-web-site.com/public_html/index.php
/PhpStorm_projects/the-web-site.com/public_html/other_file.php
/PhpStorm_projects/the-web-site.com/public_html/something_else.php
/PhpStorm_projects/the-web-site.com/.git
/PhpStorm_projects/the-web-site.com/.idea
/PhpStorm_projects/the-web-site.com/.gitignore
etc...

Then upload just the /public_html/ folder so git and working files were out of the way.

Could that work?

0
Comment actions Permalink

Thanks for your kind assistance on the forum!

0
Comment actions Permalink

:)

other people help me.

0
Comment actions Permalink

Thanks Michael. Yes, that works, and it may be the method I end up adopting, but it doesn't answer any of the questions in the OP. I think there must be a bug in phpStorm that prevents Git from tracking a remote directory. As long as the .git is next to or above the folders being tracked, it's fine, but if the .git is in an 'unrelated' folder then it doesn't track. It lets you set up the paths to the unrelated folder, but then ignores them. If Alexey doesn't drop by shortly to correct my view on this I'll add it to the bug list.

0
Comment actions Permalink

Still hoping someone can tell me how to do this:

I have my web files in this folder:

C:/project1/web

I have the .idea files here:

C:/PS_SETTINGS/project1/.idea

I want to put the .git file next to the .idea folder thus:

C:/PS_SETTINGS/project1/.git

What do I do in PS to make this happen?
Step-by-step please.

Thanks.

0
Comment actions Permalink

This is not related to IDE but to a git.
And you can easilly google it up. I.e. http://stackoverflow.com/questions/505467/can-i-store-the-git-folder-outside-the-files-i-want-tracked

Note, that ticks used to achieve this *may* render IDE's git support useless.

0
Comment actions Permalink

Yeah, googling is how I came to be a user of PS. Googling is how I know everything I know about git. Googling is how I know *how* to use PS, and I guess googling will lead me on to the next great thing.
As a single developer I regard git as just another part of PS - I don't use it for anything else. I'm forced to use it because there's no control over saving of files and no way of listing files in date order in the project pane - in other words no easy ("dumb") way of keeping track of latest changes. Of course git can be a boon, and now I've figured out how to use it I think it's ace. (listing by date would still be really handy though). As far as googling git goes, it usually seems to be a matter of opinion about how any of its functions work.
Please don't ignore my really simple question about how to use an aspect of git with PS. Please read my question, understand what it is I am asking, and if you know the answer, please impart some wisdom. At the very least you might regard it as a clue that something in PS might not be as easy to use as it could be? Not everybody around here is an expert, you know. And if I'm asking something that doesn't make any sense, please let me know and point me down the right road.
Thank you.

0
Comment actions Permalink

with another ( older ) version control system CVS you ended up with a .CSV folder in _every_ sub folder.

so
/top_folder/.CVS
/top_folder/index.php
/top_folder/images/.CVS
/top_folder/js/.CVS
/top_folder/css/.CVS

Git is better than that in that normally you only have one .git folder at the very top level of your project,

/top_folder/.git
/top_folder/index.php
/top_folder/images/
/top_folder/js/
/top_folder/css/

But what your trying to do is take it one step further and move it somewhere else entirely.  This isnt the normal way to setup git.  Its an advanced setup.

Covering advanced or special git setups might be outside the scope of the standard support.  If you do want to go with the advanced setup and do get it working perhaps listing the steps here could help others.

0
Comment actions Permalink

Bingo! Thanks Michael!

0

Please sign in to leave a comment.