简体   繁体   English

没有项目文件夹的Git更新

[英]Git update without project folder

I have setup a repository in Github. 我已经在Github中建立了一个仓库。 I have used SSH protocol to establish connection to that repo in my web hosting. 我已经使用SSH协议在我的虚拟主机中建立了与该仓库的连接。 Then I have cloned the repo without the project folder like this. 然后我克隆了没有这样的项目文件夹的仓库。

git clone git@github.com:{username}/{git-name} .

All works without any problem. 一切正常。

Now, I want to use that repo as the final copy of my website ie every time I update the repo, my website will also be updated. 现在,我想将该存储库用作网站的最终副本,即,每次更新存储库时,我的网站也将被更新。 So, I created a PHP script which contains 因此,我创建了一个PHP脚本,其中包含

`git pull`

I put the script link as web hook url in Github settings. 我在Github设置中将脚本链接作为Web钩子URL。 But nothing happens when I update my repo. 但是,当我更新我的仓库时,什么也没有发生。

I don't understand what's the problem. 我不明白这是什么问题。 Is it because I have cloned the site without repository folder? 是因为我克隆了没有存储库文件夹的站点吗?

Another problem is that, the .git folder is present inside the main website which means everyone can access that. 另一个问题是, .git文件夹位于主网站内,这意味着每个人都可以访问该文件夹。 Is there any solution to that? 有什么解决办法吗?

I am pretty much new to Git and Github. 我对Git和Github非常陌生。 So, detailed instruction will be very helpful. 因此,详细的指导将非常有帮助。 I am using Shared hosting with SSH shell access. 我正在通过SSH Shell访问使用共享主机。

You didn't told git which branch you want to pull. 您没有告诉git您要拉哪个分支。 So git pull <your-branch> should fix that problem. 因此, git pull <your-branch>应该可以解决该问题。

With a .htaccess file within the .git folder you can refuse access to it: 使用.git文件夹中的.htaccess文件,您可以拒绝访问它:

Order Allow,Deny
Deny from All

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM