在Git推送后查看网站 [英] View website live after Git push

查看:393
本文介绍了在Git推送后查看网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能存在重复:






<



当我将本地生产存储库推送到远程临时存储库时,我希望立即生效能够实时查看我新推送的文件。当我尝试在远程存储库中查找我的文件时(通过FTP客户端),我无法找到它们。



我是否需要执行一些高级Git魔术为了实现这个(挂钩?)?对于这种情况,最佳做法是什么?

再一次,我是Git的新手,并没有完全理解这个概念。也许值得注意的是,我为远程存储库使用了 Webfaction Git应用程序



编辑:我看到,我知道如何创建post-commit hook,但我不知道应该在shell脚本中放置什么。

首先,你不想使用post-commit钩子 - 这是一个客户端钩子。你想要的服务器端钩子将被接收后或更新(取决于你是否使用分支)。



请参阅: https://git-scm.com/book/en/v2/Customizing-Git-Git -Hooks



在你的hook脚本中,你应该chdir到服务器文档根目录并运行git pull。另外,在脚本的顶部,确保包含

  unset GIT_DIR 



否则git会在您尝试拉动时混淆。


Possible Duplicate:
Git Post-Receive Hook for Website Staging

I started learning Git today and I'm stuck on one thing.

When I push my local production repository to my remote staging repository, I would like to immediately be able to view my newly pushed files live. When I try to look for my files in my remote repository (via an FTP client), I can't find them.

Do I need to perform some advanced Git magic in order to achieve this (hooks?)? What is best practice for this situation?

Again, I'm new to Git and don't fully understand the concept yet. Maybe it's worth noting that I use a Webfaction Git application for the remote repository.

Edit: I saw this topic on SO, and I know how to create a post-commit hook but I have no idea what to put in the shell script.

解决方案

First off, you don't want to use a post-commit hook - that's a client-side hook. The server-side hook you want will be either post-receive or update (depending on whether you're using branches).

See: https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks

In your hook script, you should chdir to the server document root and run a git pull. Also, at the top of the script, make sure to include

unset GIT_DIR

otherwise git will confuse itself when you try to pull.

这篇关于在Git推送后查看网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆