Reputation: 1058
I have just started trying to learn Git and I have got a little stuck. We are using Github to hold our "stable" project but I am having trouble working with the repo.
I want to know if its possible to use a local webservers htdocs/[projectname]
as the working directory - this way I could clone the repo from github, work on it on the local server ( so it works as the application should allowing me to test everything i write properly ) and then stage -> commit from there.
I am working on a Mac using the MAMP environment. The application is a PHP based CMS. We are holding it on Github on a private repository. Currently Git seems to be using /Users/Ben/Core-CMS
as the working dir but this makes it very hard to test things out - it would be much better if the working dir was inside the apache htdocs dir
I bought Pro Git but I am having a very hard time learning the concepts of git - I have purposely avoided using the GUI's as I wish to learn the inner workings of Git properly before I start 'cheating'!
Upvotes: 5
Views: 7111
Reputation: 1901
This should not be a problem. I'm doing this all the time.
Switch to your public directory and run:
git clone REPO_URL NAME_OF_DIR_TO_CLONE_TO
first.
The dir where you clone a git repository must not exist.
You just need a ssh key authorized to push your changes from the repository to github and git installed on the server (or in your client if you have mounted everything to your local machine).
Then you do you commit which is just local and if you are done you may push your changes to github.
Another way would be to make the webserver use your working directory as its DocumentRoot
.
I hope I didn't miss your problem here ;)
Upvotes: 1
Reputation: 13675
If you have the permission to write in the htdocs
dir, just move /Users/Ben/Core-CMS
to htdocs/Core-CMS
and access it at http://localhost/Core-CMS
.
If you cannot write in the htdocs
dir, I'd create /Users/Ben/web
, put my projects in there and tell apache to serve from there. To tell apache to look in /Users/Ben/web
to serve your projects, look for the following line in your apache conf:
DocumentRoot /path/to/htdocs
and replace it with:
DodumentRoot /Users/Ben/web
Upvotes: 8