草庐IT

Git工作流程(Dev>Staging>Live)基本技术问题

coder 2023-06-25 原文

我对 Git(和 VC 而言)还很陌生,我有点难以理解 Dev>Staging>Live workflow using branches 背后的概念。

我正在尝试应用 this 的一部分 工作流,它使用 dev 分支和 release 分支而不是固定的 staging

在尝试使用 Git 之前,我有使用 SVN 的“相同”工作流程。但是我们没有为每个阶段创建分支,而是为它使用了单独的存储库。现在我正在尝试应用分支,事情变得有点模糊。

我能理解工作流背后的想法,但无法从技术角度理解它。

创建它所遵循的步骤:

创建文件夹

user:/var/www/$ mkdir dev.example.local
user:/var/www/$ mkdir staging.example.local
user:/var/www/$ mkdir example.local

初始化存储库

user:/var/www/example.local$ git init
user:/var/www/example.local$ git remote add origin git@bitbucket.org:user/example.com.git
user:/var/www/example.local$ echo "README" > README
user:/var/www/example.local$ git commit -am "First"
user:/var/www/example.local$ git push origin master

user:/var/www/example.local$ cd ../dev.example.com
user:/var/www/dev.example.local$ git clone git@bitbucket.org:user/example.com.git .
user:/var/www/dev.example.local$ git checkout -b dev
user:/var/www/dev.example.local$ git push origin dev

user:/var/www/dev.example.local$ cd staging.example.com
user:/var/www/staging.example.local$ git clone git@bitbucket.org:user/example.com.git .

开发分支的一些工作

user:/var/www/dev.example.local$ echo "New" > newfile
user:/var/www/dev.example.local$ git add .
user:/var/www/dev.example.local$ git commit -am "Some new file"
user:/var/www/dev.example.local$ git push origin dev

当新版本准备就绪时

user:/var/www/staging.example.local$ git fetch
user:/var/www/staging.example.local$ git checkout -b release-0.1 dev
user:/var/www/staging.example.local$ git push origin release-0.1

user:/var/www/staging.example.local$ cd ../example.com
user:/var/www/example.local$ git fetch
user:/var/www/example.local$ git merge --no-ff origin/release-0.1
user:/var/www/example.local$ git tag -a "0.1"
user:/var/www/example.local$ git push origin master

user:/var/www/example.local$ cd ../dev.example.com
user:/var/www/example.local$ git merge --no-ff master
user:/var/www/example.local$ git push origin dev

我很确定我没有遵循正确的步骤。那么,什么是“正确的方法”:

  • 创建 devstaginglive 文件夹并在每个文件夹中初始化 git 存储库?
  • checkout /merge 新版本?
  • release merge 到live
  • 创建整个环境?

和:

  • 我应该在哪里运行这些 git 命令?在我的本地 repo ?对于每个阶段?

相关信息:

  • 我正在使用 BitBucket
  • 这是用于网站 (Drupal) 开发的
  • 我的master 分支是live 阶段
  • 大约有 3 名开发人员同时工作,每个开发人员在不同的国家/地区

最佳答案

您不需要创建不同的存储库。您应该学习并且您可能会喜欢 git 的是使用分支是多么容易。所以第 1 步:

  • 忘掉你从 SVN 背景中知道的一切

既然我们都准备好了,那就是想法。假设您的 bitbucket 目前只有 master:

  • 克隆存储库:

    $ git clone git@bitbucket.org:user/example.com.git
    $ cd example.com
    
  • 创建您的分支:

    $ git branch dev
    $ git branch staging
    
  • 让其他人知道这些分支:

    $ git push origin dev
    $ git push origin staging
    
  • 开始工作吧!

    $ git checkout dev
    $ touch new_file
    $ git add new_file
    $ git commit
    $ git merge master         # and resolve conflicts
    $ git checkout master
    $ git merge dev
    $ git push origin
    

注意:上面的示例是一个简单的分支-实验- merge ,可能不会反射(reflect)您教程中的确切工作流程。

简而言之,您没有不同的存储库,而是在一个存储库中分支。在这些分支之间,您可以根据需要与任何您喜欢的工作流程 merge 。您可以有额外的分支,这些分支不会被推送到原点,因此它们对其他人是 stash 的。当然,您还应该经常 git fetch/git merge 您想要处理的分支,以确保您从其他协作者那里获得最新的更改。

关于Git工作流程(Dev>Staging>Live)基本技术问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11461680/

有关Git工作流程(Dev>Staging>Live)基本技术问题的更多相关文章

  1. ruby-on-rails - 由于 "wkhtmltopdf",PDFKIT 显然无法正常工作 - 2

    我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-

  2. ruby-on-rails - 'compass watch' 是如何工作的/它是如何与 rails 一起使用的 - 2

    我在我的项目目录中完成了compasscreate.和compassinitrails。几个问题:我已将我的.sass文件放在public/stylesheets中。这是放置它们的正确位置吗?当我运行compasswatch时,它不会自动编译这些.sass文件。我必须手动指定文件:compasswatchpublic/stylesheets/myfile.sass等。如何让它自动运行?文件ie.css、print.css和screen.css已放在stylesheets/compiled。如何在编译后不让它们重新出现的情况下删除它们?我自己编译的.sass文件编译成compiled/t

  3. ruby-on-rails - 如何从 format.xml 中删除 <hash></hash> - 2

    我有一个对象has_many应呈现为xml的子对象。这不是问题。我的问题是我创建了一个Hash包含此数据,就像解析器需要它一样。但是rails自动将整个文件包含在.........我需要摆脱type="array"和我该如何处理?我没有在文档中找到任何内容。 最佳答案 我遇到了同样的问题;这是我的XML:我在用这个:entries.to_xml将散列数据转换为XML,但这会将条目的数据包装到中所以我修改了:entries.to_xml(root:"Contacts")但这仍然将转换后的XML包装在“联系人”中,将我的XML代码修改为

  4. ruby - 无法让 RSpec 工作—— 'require' : cannot load such file - 2

    我花了三天的时间用头撞墙,试图弄清楚为什么简单的“rake”不能通过我的规范文件。如果您遇到这种情况:任何文件夹路径中都不要有空格!。严重地。事实上,从现在开始,您命名的任何内容都没有空格。这是我的控制台输出:(在/Users/*****/Desktop/LearningRuby/learn_ruby)$rake/Users/*******/Desktop/LearningRuby/learn_ruby/00_hello/hello_spec.rb:116:in`require':cannotloadsuchfile--hello(LoadError) 最佳

  5. ruby-on-rails - rspec should have_select ('cars' , :options => ['volvo' , 'saab' ] 不工作 - 2

    关闭。这个问题需要detailsorclarity.它目前不接受答案。想改进这个问题吗?通过editingthispost添加细节并澄清问题.关闭8年前。Improvethisquestion在首页我有:汽车:VolvoSaabMercedesAudistatic_pages_spec.rb中的测试代码:it"shouldhavetherightselect"dovisithome_pathit{shouldhave_select('cars',:options=>['volvo','saab','mercedes','audi'])}end响应是rspec./spec/request

  6. ruby-on-rails - s3_direct_upload 在生产服务器中不工作 - 2

    在Rails4.0.2中,我使用s3_direct_upload和aws-sdkgems直接为s3存储桶上传文件。在开发环境中它工作正常,但在生产环境中它会抛出如下错误,ActionView::Template::Error(noimplicitconversionofnilintoString)在View中,create_cv_url,:id=>"s3_uploader",:key=>"cv_uploads/{unique_id}/${filename}",:key_starts_with=>"cv_uploads/",:callback_param=>"cv[direct_uplo

  7. ruby-on-rails - Nokogiri:使用 XPath 搜索 <div> - 2

    我使用Nokogiri(Rubygem)css搜索寻找某些在我的html里面。看起来Nokogiri的css搜索不喜欢正则表达式。我想切换到Nokogiri的xpath搜索,因为这似乎支持搜索字符串中的正则表达式。如何在xpath搜索中实现下面提到的(伪)css搜索?require'rubygems'require'nokogiri'value=Nokogiri::HTML.parse(ABBlaCD3"HTML_END#my_blockisgivenmy_bl="1"#my_eqcorrespondstothisregexmy_eq="\/[0-9]+\/"#FIXMEThefoll

  8. ruby - JetBrains RubyMine 3.2.4 调试器不工作 - 2

    使用Ruby1.9.2运行IDE提示说需要gemruby​​-debug-base19x并提供安装它。但是,在尝试安装它时会显示消息Failedtoinstallgems.Followinggemswerenotinstalled:C:/ProgramFiles(x86)/JetBrains/RubyMine3.2.4/rb/gems/ruby-debug-base19x-0.11.30.pre2.gem:Errorinstallingruby-debug-base19x-0.11.30.pre2.gem:The'linecache19'nativegemrequiresinstall

  9. Unity 热更新技术 | (三) Lua语言基本介绍及下载安装 - 2

    ?博客主页:https://xiaoy.blog.csdn.net?本文由呆呆敲代码的小Y原创,首发于CSDN??学习专栏推荐:Unity系统学习专栏?游戏制作专栏推荐:游戏制作?Unity实战100例专栏推荐:Unity实战100例教程?欢迎点赞?收藏⭐留言?如有错误敬请指正!?未来很长,值得我们全力奔赴更美好的生活✨------------------❤️分割线❤️-------------------------

  10. ruby - `rescue $!` 是如何工作的? - 2

    我知道全局变量$!包含最新的异常对象,但我对下面的语法感到困惑。谁能帮助我理解以下语法?rescue$! 最佳答案 此构造可防止异常停止您的程序并使堆栈跟踪冒泡。它还会将该异常作为值返回,这很有用。a=get_me_datarescue$!在此行之后,a将保存请求的数据或异常。然后您可以分析该异常并采取相应措施。defget_me_dataraise'Nodataforyou'enda=get_me_datarescue$!puts"Executioncarrieson"pa#>>Executioncarrieson#>>#更现实的

随机推荐