简体   繁体   English

从git repo安装和更新项目的本地副本

[英]Installing and updating local copy of project from git repo

I'm currently developing a small blogging system for use on two different websites (maybe more in time) that I plan to host on github. 我目前正在开发一个小型博客系统,供计划在github上托管的两个不同网站(可能会更及时)使用。 While I understand the development side of git (adding files, committing changes, pushing to a remote) I'm struggling to understand the deployment side. 虽然我了解git的开发方面(添加文件,提交更改,推送到远程),但我仍在努力了解部署方面。 What I would like to know is how I would 我想知道的是我会如何

  1. install the initial copy of the code necessary for the site and 安装该站点所需代码的初始副本,并

  2. grab updates to that code after the repository has been updated 存储库更新后,获取该代码的更新

Similar to WordPress, the baseline code will include a sample config file that needs to be copied and edited as well as an empty directory used for client uploads. 与WordPress相似,基准代码将包括一个需要复制和编辑的示例配置文件,以及一个用于客户端上传的空目录。 Here's how I think the process should flow along. 我认为这是应该进行的过程。

  1. Development - write code, commit, push 开发-编写代码,提交,推送
  2. Development - more code, commits, pushes 开发-更多代码,提交,推送
  3. Production - install software (how?) 生产-安装软件(如何?)
  4. Development - code again, commit, push 开发-再次编码,提交,推送
  5. Production - update local install (how?) 生产-更新本地安装(如何?)

Steps 3 and 5 are where I'm missing something. 步骤3和5是我遗漏的内容。 I've read about cloning, fetching, and pulling but I don't think they are what I need for this scenario. 我已经读过有关克隆,获取和拉取的信息,但我认为在这种情况下我不需要它们。

I'm trying to figure out how I can grab the initial copy of the code plus grab updates while ensuring the following: 我试图弄清楚如何在确保以下内容的同时获取代码的初始副本以及获取更新:

  1. I don't end up with the entire git repository history of the project in each install, just the current version of the files. 我不会在每次安装时都得到项目的整个git存储库历史记录,而只是文件的当前版本。
  2. Pulling updates only overwrites/deletes tracked code files and leaves things like the copied config file and uploads directory as-is 仅提取更新会覆盖/删除跟踪的代码文件,并保留复制的配置文件之类的内容并按原样上传目录

What command(s) do I need to do this? 我需要执行什么命令?

To push new code to the server and have the server automatically update its code, you will want to use a "bare" git repository along with a git hook. 要将新代码推送到服务器并使服务器自动更新其代码,您将需要使用“裸” git存储库以及git钩子。 See this page for instructions: http://toroid.org/git-website-howto 有关说明,请参见此页面: http : //toroid.org/git-website-howto

To avoid deleting or overwriting files, it sounds like what you're looking for is the .gitignore file. 为了避免删除或覆盖文件,听起来您正在寻找的是.gitignore文件。 From git's documentation ( https://git-scm.com/docs/gitignore ): 从git的文档( https://git-scm.com/docs/gitignore ):

A gitignore file specifies intentionally untracked files that Git should ignore. gitignore文件指定Git应该忽略的故意未跟踪的文件。 Files already tracked by Git are not affected 已被Git跟踪的文件不受影响

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

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