Executing the command git clone git@github.com:whatever
creates a directory in my current folder named whatever, and drops the contents of the Git repository into that folder:
/httpdocs/whatever/public
My problem is that I need the contents of the Git repository cloned into my current directory so that they appear in the proper location for the web server:
/httpdocs/public
I know how to move the files after I've cloned the repository, but this seems to break Git, and I'd like to be able to update just by calling git pull
. How can I do this?
To clone git repository into a specific folder, you can use
-C <path>
parameter, e.g.Although it'll still create a
whatever
folder on top of it, so to clone the content of the repository into current directory, use the following syntax:Note that cloning into an existing directory is only allowed when the directory is empty.
Since you're cloning into folder that is accessible for public, consider separating your Git repository from your working tree by using
--separate-git-dir=<git dir>
or exclude.git
folder in your web server configuration (e.g. in.htaccess
file).When you move the files to where you want them, are you also moving the
.git
directory? Depending on your OS and configuration, this directory may be hidden.It contains the repo and the supporting files, while the project files that are in your
/public
directory are only the versions in the currently check-out commit (master branch by default).Regarding this line from the original post:
I am able to do that and I don't see any issues so far with my add, commit, push, pull operations.
This approach is stated above, but just not broken down into steps. Here's the steps that work for me:
The existing folder you just copied the files into , is now ready to interact with git.