使用git在现有网站上管理网站 [英] Managing website with git on a existing website

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

问题描述

我一直在阅读教程,并且仍然无法开始使用git维护我的网站。



Git在我的托管服务提供商处设置。我有一个文件夹将被更新,并且我有一个本地副本。我已经做了一些改变,但 git push origin master 命令并不是什么都没有。



我想我设法设置远程URL指向 .git / config 。当我尝试 git remote show origin 它说:

  * remote origin 
获取URL:ssh://路径到文件夹
推送URL:ssh://路径到文件夹
HEAD分支:(不明)

我在我想要更新的远程文件夹中键入 git init --bare



这是我失去跟踪的部分。我不明白接下来的步骤是什么?基本上,我想上传我的本地文件在我的服务器上的文件夹,当我在本地进行更改时,我希望能够在线推送它,因此我不必使用FTP。

我认为这里的误解是你正在尝试使用Git将更改上传到你的网站。它可以被塞进做到这一点,但这是一个糟糕的Git使用。 Git不是发布管理器。有两种处理方式。



一种是纯粹将Git用作版本控制系统。它会记录您何时以及为什么进行更改。使用其他方法将这些文件上传到您的生产Web服务器。



另一个是再次使用Git作为版本控制系统,但您也可以使用它部署您的更改。主要的是 你不能/不应该使用Git将更改推送到生产 。相反,将更改推送到中央裸仓库,这可以是Github或服务器上的其他目录,然后 将更改提交到生产 。 b
$ b

简单地说...


  1. 本地编辑和提交。


  2. ssh传送到您的生产服务器。

  3. 转至您的生产结帐。

  4. 从中央存储库中提取。

此设置的优点是您可以在生产中完成结帐,知道你已经安装了什么版本。你也可以通过 git diff 来判断它是否被热补丁,你可以提交并推送这些热补丁。



缺点是你的发布/安装过程只是复制文件。每个文件都必须准备好。另一个要小心的是 .git 目录对公众不可见。


I've been reading tutorials all day, and I still can't start to maintain my website with git.

Git is set on my hosting provider. I have one folder which will be updated, and I have a local copy of it. I already made some changes but git push origin master command doesn't nothing.

I think I managed to set remote URL to .git/config. When I try git remote show origin it says:

* remote origin
  Fetch URL: ssh://path to folder
  Push  URL: ssh://path to folder
  HEAD branch: (unknown)

I also typed git init --bare in my remote folder I want to update.

This is the part where I lose track. I don't understand what are the next steps? Basically, I want to upload my local files on that folder on my server and when I make changes locally I want to be able to push it online so I don't have to use FTP.

解决方案

I think the misunderstanding here is you're trying to use Git to upload changes to your web site. It can be crammed into doing that, but it's a poor use of Git. Git is not a release manager. There's two ways of handling this.

One is to use Git purely as a version control system. It records when and why you made changes. Use something else to upload those files to your production web server.

The other is to, again, use Git as a version control system, but you can also use it to deploy your changes. The main thing is that you cannot/should not use Git to push changes to production. Instead, push your changes to a central bare repository, this could be Github or a different directory on your server, and then pull the changes to production.

In brief...

  1. Edit and commit locally.
  2. Push to a central repository.
  3. ssh to your production server.
  4. cd to your production checkout.
  5. Pull from the central repository.

The advantages of this setup is you have a complete checkout in production, so you always know what version you have installed. You also can tell if it's been hot patched with git diff and you can commit and push those hot patches back.

The disadvantage is your release/install process is just copying files. Each file has to be ready to go. Another is to be careful that the .git directory is not visible to the public.

这篇关于使用git在现有网站上管理网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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