Git工作流程(Dev> Staging> Live)的基本技术问题 [英] Git workflow (Dev>Staging>Live) basic technical questions

查看:183
本文介绍了Git工作流程(Dev> Staging> Live)的基本技术问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


$ b $对于Git(和VC来说)我很新,而且我正在努力了解使用分支的Dev> Staging> Live工作流背后的概念。 b

我尝试应用 工作流,它使用 dev 分支和版本分支而不是固定的分段

在尝试使用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 -amFirst
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

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

开发分支的一些工作

  user:/var/www/dev.example.local$ echoNew> newfile 
user:/var/www/dev.example.local$ git add。
user:/var/www/dev.example.local$ git commit -am一些新文件
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 -a0.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

我很确定我没有关注正确的步骤。那么,正确的方式是什么:




  • 创建 dev staging live 文件夹,并在其中的每一个文件夹中初始化git repo?

  • 版本合并到 live
  • $ b

    • 我应该在哪里运行这些git命令?在我的本地回购?为每一个阶段?



    相关信息:


    • 我使用BitBucket

    • 这是用于网站(Drupal)开发

    • / em>分支是 live 阶段

    • 大约有3位开发人员同时工作,并且每个人都在不同的国家工作


    解决方案

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


    • 忘掉你从SVN背景知道的任何东西


    现在我们全都准备好了,这里有个想法。假设您目前只有 master 在您的bitbucket上:




    • 克隆存储库:

        $ git clone git@bitbucket.org:user / example.com.git 
      $ cd例子.com


    • 创建您的分行:

        $ git branch dev 
      $ git branch staging


      让其他人知道这些分支:

      pre code $ git push origin dev $ b $ git push origin暂存


    • 开始工作!

        $ git checkout dev 
      $ touch new_file
      $ git add new_file
      $ git commit
      $ git merge master#并解决冲突
      $ git checkout master
      $ git merge dev
      $ git push origin


    • ul>

      注意:上面的例子是一个简单的分支实验合并,可能不会像您的教程那样反映确切的工作流程。



      S o简而言之,您没有不同的存储库,但分支存储在单个存储库中。在这些分支之间,您可以尽可能多地合并您喜欢的任何工作流程。你可以有额外的分支不被推送到原点,所以他们对其他人隐藏。你当然也应该经常使用 git fetch / git merge 你想要工作的分支,以确保你得到来自其他合作者的最新变化。


      I'm quite new to Git (and VC for that matter) and I'm struggling a bit to understand the concept behind the Dev>Staging>Live workflow using branches.

      I'm trying to apply part of this workflow, that uses dev branches and release branches instead of a fixed staging.

      Before trying to use Git, I had the "same" workflow using SVN. But instead of creating branches for each stage, we used separated repositories for it. Now that I'm trying to apply branches, things are getting a bit blurry.

      I can understand the idea behind the workflow, but can't get it from a technical point of view.

      The steps that I'm following to create it:

      Create folders

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

      Init repositories

      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 .
      

      Some work on dev branch

      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
      

      When things are ready for a new release

      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
      

      I'm pretty sure I'm not following the correct steps. So, what's the "right way" to:

      • create the dev, staging, live folders and init the git repo in each one of them?
      • checkout/merge new releases?
      • merge from the release to live?
      • create the whole environment?

      And:

      • where should I run those git commands? on my local repo? for each one of the stages?

      Relevant info:

      • I'm using BitBucket
      • This is for website (Drupal) development
      • My master branch is the live stage
      • There are about 3 developers working at the same time, and each one in a different country

      解决方案

      You don't need to create different repositories. What you should learn and you'll probably love about git is how easy it is to work with branches. So step 1:

      • Forget about anything you know from your SVN background

      Now that we are all set, here is the idea. Let's say you have currently only master on your bitbucket:

      • Clone the repository:

        $ git clone git@bitbucket.org:user/example.com.git
        $ cd example.com
        

      • Create your branches:

        $ git branch dev
        $ git branch staging
        

      • Let others know about these branches:

        $ git push origin dev
        $ git push origin staging
        

      • Start working!

        $ 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
        

      Note: The example above is a simple branch-experiment-merge, and would probably not reflect the exact workflow as your tutorial.

      So in short, you don't have different repositories, but branches in a single repository. Between these branches, you can merge as much as you want with whatever workflow you like. You can have additional branches that are not pushed to origin, so they are hidden from others. You should also of course git fetch/git merge the branches you want to work on every often to make sure you get the latest changes from other collaborators.

      这篇关于Git工作流程(Dev> Staging> Live)的基本技术问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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