我可以使用git让远程服务器保持最新状态吗?

编程入门 行业动态 更新时间:2024-10-27 02:25:06
本文介绍了我可以使用git让远程服务器保持最新状态吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用git来跟踪一个项目,如果可能的话,我想设置一些东西,以便git处理我所有的代码分段,我可以有一个本地存储库用于测试,然后将更改推送到服务器用git让他们活下去。然而,在尝试使用标准的 git push 调用时,我最终会遇到不一致的分支以及可怕的历史冲突。有没有办法使用git来管理登台?

I'm using git to track a project, and if it's possible, I'd like to set things up so git handles all my code staging, I can have a local repository for testing, and then push changes to the server with git to make them live. However, in trying to use standard git push calls, I just end up with inconsistent branching and a terrible mess of conflicting histories. Is there a way to manage staging using git?

推荐答案

您有这个

You have in this blog post an example of Git repo used for staging:

IDE => local Git repository => remote bare Git repository => Git repository with the live web application

它涉及裸回购方面的更新后钩子,为了触发活动Web服务器端的回购更新。

It involves a post-update hook on the bare repo side, in order to trigger the update of the repo on the live web server side.

最后一步是定义更新后钩子裸仓库接收数据时调用该脚本。 要启用后更新钩子,我们必须使 hooks / post-update 可执行文件或重命名 hooks / post-update.sample 至 hooks / post-update 在这个脚本中,我们只需切换到实时应用程序的文件夹,然后启动pull操作:

The final step is to define the "post-update" hook script on the bare repository, which is called when the bare repository receives data. To enable the "post-update" hook, we have to either make hooks/post-update executable or rename hooks/post-update.sample to hooks/post-update, depending on the Git version. In this script, we simply change to the folder of the live application, and start the pull operation:

#!/bin/sh cd $HOME/example unset GIT_DIR git pull bare master exec git-update-server-info

有一个裸露的远程回购是因为它不鼓励用工作目录进行回购。

The reason there is a bare remote repo is because it is "discouraged" to do a push into a repo with a working directory.

更多推荐

我可以使用git让远程服务器保持最新状态吗?

本文发布于:2023-08-07 13:40:13,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:可以使用   状态   服务器   最新   git

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!