简体   繁体   English

如何在不引入大量开销的情况下将git添加到我的工作流程中?

[英]How can I add git to my workflow without introducing extensive overhead?

Currently my web development workflow for live sites is pretty broken and I am looking to improve the process. 目前,我的实时网站开发工作流程已经中断,我正在寻求改进流程。 I have no version control and am more often than not doing direct edits over FTP to the live site. 我没有版本控制,通常比不通过FTP直接编辑实时站点更多。 Because of that, this is a new workflow I am thinking of implementing and would love your feedback. 因此,这是我正在考虑实施的新工作流程,希望您能提供反馈。 Along the same lines, feel free to let me know "that workflow is stupid... you should do X instead". 同样,随时让我知道“工作流程很愚蠢……您应该改用X”。

Goals/hopes/dreams: 目标/希望/梦想:

  • No requirement for local box to have a full dev environment (WAMP, etc) 不需要本地机器具有完整的开发环境(WAMP等)
  • Uses Git 使用Git
  • Minimal overhead (I'm a one man shop and don't want to have a million branches to deal with, etc) 最小的开销(我是一个单人商店,不想拥有一百万个分支机构来应对,等等)

Proposed Workflow: 拟议的工作流程:

  • Two sites: 两个站点:
    • site.com - My live site lives here site.com-我的实时站点居住在这里
    • beta.site.com - Copy of my site lives here beta.site.com-我的网站的副本位于此处
  • All work is done remotely over FTP on the beta.site.com site. 所有工作都是通过beta.site.com网站上的FTP远程完成的。 This allows me to use my web server as my "dev box" 这使我可以将Web服务器用作我的“开发箱”
  • Once the change/feature I am working on is complete, I perform a commit to my only branch ("live") 完成我要处理的更改/功能后,我将提交到我唯一的分支(“活动”)
  • The live branch has a post-hook that copies the changes over to the live site at site.com 实时分支有一个挂机,可将更改复制到site.com的实时站点。
  • If I run into any issues I can simply rollback the live branch which will in turn re-deploy the last working version of the site 如果遇到任何问题,我可以简单地回滚实时分支,这将反过来重新部署该站点的上一个工作版本

I know this isn't the most ideal workflow as I technically don't have a true staging environment, etc but seeing as I am just a one person dev team I feel like this may be sufficient. 我知道这不是最理想的工作流程,因为从技术上讲我没有真正的暂存环境等,但是看到我只是一个人的开发团队,我觉得这可能就足够了。 Also, since I'm coming from live FTP edits to the site, I know that if I introduce too much overhead I'll end up just editing the site again after a short period and I want to make sure I stick with this new method. 另外,由于我来自现场FTP编辑,所以我知道如果引入过多的开销,我将在短时间后再次编辑该站点,我想确保自己坚持使用这种新方法。

Anywho, anyone have any thoughts or suggestions on this approach? 谁对此方法有任何想法或建议? Would love to hear the feedback of the more seasoned devs here. 很想听听这里经验丰富的开发人员的反馈。

Above everything else, I'd like to stress one thing. 最重要的是,我想强调一件事。 If you take nothing else from this answer, please think about this. 如果您没有其他答案,请考虑一下。 Regardless of your workflow, you should always use some form of version control. 无论您的工作流程如何,都应始终使用某种形式的版本控制。 Using version control has many benefits, not the least of which is providing you some piece of mind that your code is safe, but it will also allow you to develop code faster. 使用版本控制有很多好处,其中最重要的一点是使您确信代码是安全的,但同时也可以使您更快地开发代码。 I don't have the book in front of me, so I can't provide an exact reference, but Steve McConnell's book "Rapid Development: Taming Wild Software Schedules" hits on the topic again and again if you need some convincing that version control will actually save you time instead of "introducing extensive overhead." 我没有这本书,因此无法提供确切的参考,但是如果您需要一些令人信服的版本控制,史蒂夫·麦康奈尔(Steve McConnell)的书“快速开发:驯服野性软件计划”将一再提及该主题。实际上将节省您的时间,而不是“引入大量开销”。

Why did I start out an answer to a question about a workflow like this? 为什么我要开始回答有关这样的工作流程的问题? Regardless of what else you change in your workflow, you can begin integrating git immeadiatly with very little overhead. 不管还有什么,你在你的工作流程改变,你就可以开始用很少的开销immeadiatly整合饭桶。 Adding git to your site is as simple as navigating to your working directory and typing git init . 将git添加到您的站点就像导航到工作目录并键入git init一样简单。 That's it, you now have a git repository that you can check code into. 就是这样,您现在有了一个git存储库,可以将代码检入其中。

I won't pretend that there isn't a little bit of a learning curve to git. 我不会假装git没有一点学习曲线。 One of the programs biggest drawbacks in my opinion is that it isn't very user-friendly to those unfamiliar with it. 我认为该程序的最大缺点之一是,它对那些不熟悉它的用户不是很友好。 Don't let that daunt you though, once you sort of grok git, all of the commands make sense and actually accomplishing stuff will be pretty straight forward. 但是,不要让那让您望而却步,一旦您了解了git git,所有的命令就有意义了,并且实际上完成工作将非常简单。 For help with finding that "AH-HA!" 为了帮助您找到“ AH-HA!” moment, please see think-like-a-git or the excellent git internals book. 此刻,请参阅git-like或优秀的git内部手册。

Now on to the good part, Improving your workflow. 现在好了,改善您的工作流程。 Generally, I like the workflow you've suggested, and I bet it will be a big improvement over what you are doing now. 通常,我喜欢您建议的工作流程,并且我敢打赌,它将比您现在正在做的工作有很大的改进。 I don't think you should do anything radically different from what you suggested. 我认为您不应做与建议完全不同的任何事情。 Instead, lets turn it up to 11 ! 取而代之的是将其设置为11

Here are my suggestions: 这是我的建议:

  • Don't worry too much about only having one branch in git. 不要太担心git中只有一个分支。 Branches are super easy to create and manage in git, much much easier than they are in something like subversion. 在git中创建和管理分支非常容易,比在subversion之类的分支中要容易得多。 I'd recommend you use something like the git-flow strategy , with your master branch representing the code that gets pushed over to your live and beta servers. 我建议您使用诸如git-flow策略之类的东西,您的master分支代表将代码推送到活动和Beta服务器的代码。
  • If you can ssh into your server and install git on it, you can actually use git to replace the ftp part of your workflow. 如果您可以ssh进入服务器并在其上安装git,则实际上可以使用git替换工作流的ftp部分。 By "pulling" from your development machine to your live server, you could more precisely control what code is deployed there, and rolling back errors would be as easy as doing new git checkout . 通过从开发计算机“拉”到活动服务器,您可以更精确地控制在其中部署了什么代码,并且回滚错误就像进行新的git checkout一样容易。
  • I'd recommend using some sort of external service to backup your git repository. 我建议使用某种外部服务来备份您的git存储库。 This provides a layer of security in case of a disaster. 这在发生灾难时提供了一层安全保护。 This is a bit grim, but remember that if your house burns down, backups to an external hard drive won't save you. 这有点严峻,但是请记住,如果您的房屋被烧毁,则备份到外部硬盘驱动器将无法为您提供帮助。 Bitbucket.org provides free private git repository hosting for small groups of people, which would be ideal for your situation. Bitbucket.org为少数人群提供免费的私人git存储库托管,这将非常适合您的情况。 If nothing else, you could use a service like Dropbox or SpiderOak to backup your working directory. 如果没有其他问题,您可以使用DropboxSpiderOak之类的服务来备份您的工作目录。

As a final note, I'd recommend that you checkout Atlassian's Source Tree git software. 最后,我建议您检出Atlassian的Source Tree git软件。 In my opinion, this is the best windows git client out there. 我认为,这是最好的Windows git客户端。 It even provides tools for doing git-flow! 它甚至提供了执行git-flow的工具!

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

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