简体   繁体   中英

Git: Created a local and remote repositories, how can I use the files I pushed to the remote repository?

I've already created two repositories - a local(on my machine) and a remote (from a live server). The remote one is a bare repository. The files are all HTML files.

Now my question is, how can I use those files I pushed to the remote one so that they may be accessible through the web? Should I create another repository from the live server and pull that one from a bare repository? Or will symlink work for this?

If you have created a bare repository on the server, then it won't contain a working tree with the files visible. This is typically what you want for a remote store.

However, if you want to serve the files via a webserver, you need to have access to the working tree, and you are right - cloning the bare repo to the served web directory will allow you (and the webserver) to access the files.

If you want to navigate the git repo itself via the web (ie look at the logs etc) then you'll need to install git-daemon and point it to the bare git repo.

恕我直言,最好的解决方案是在服务器上配置git push hook脚本,它将脚本从裸仓库(猜测,主分支)克隆/更新到WEB源文件夹。

I was able to solve my issue by cloning my remote repo.

eg

my remote repo is located in

/home/user/repo/mywebsite.git

so inside my

/var/www/mywebsite

I did git clone /home/user/repo/mywebsite.git .

Then if I push to my remote repo which is /home/user/repo/mywebsite.git , I'll just do git pull in /var/www/mywebsite

I hope this will help those having same issue as me because git-daemon didn't work well for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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