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

dmm*_*mmd 10 git workflow bitbucket

我对Git(和VC这个问题)很陌生,我正在努力了解使用分支机构开发Dev> Staging> Live工作流程背后的概念.

我正在尝试应用工作流的一部分,它使用dev分支和发布分支而不是固定的分段.

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

我可以理解工作流程背后的想法,但无法从技术角度来理解它.

我正在创建它的步骤:

创建文件夹

user:/var/www/$ mkdir dev.example.local
user:/var/www/$ mkdir staging.example.local
user:/var/www/$ mkdir example.local
Run Code Online (Sandbox Code Playgroud)

初始存储库

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 .
Run Code Online (Sandbox Code Playgroud)

一些关于dev分支的工作

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
Run Code Online (Sandbox Code Playgroud)

当事情准备好发布新版本时

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
Run Code Online (Sandbox Code Playgroud)

我很确定我没有遵循正确的步骤.那么,"正确的方式"是什么:

  • 创建dev,staging,live文件夹并在每个文件夹中初始化git repo?
  • 结帐/合并新版本?
  • 合并从发布生活
  • 创造整个环境?

和:

  • 我应该在哪里运行那些git命令?在我当地的回购?对于每一个阶段?

相关信息:

  • 我正在使用BitBucket
  • 这是针对网站(Drupal)的开发
  • 我的分支是现场舞台
  • 大约有3名开发人员在同一时间工作,每个开发人员在不同的国家/地区工作

Sha*_*baz 13

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

  • 忘记你从SVN背景知道的任何事情

现在我们都已经确定了,这就是我们的想法.假设您目前只master在您的bitbucket上:

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

简而言之,您没有不同的存储库,而是在单个存储库中具有分支.在这些分支之间,您可以根据需要合并您喜欢的任何工作流程.您可以拥有未推送到原点的其他分支,因此它们对其他分支是隐藏的.当然,您还应该经常git fetch/ git merge希望每个分支机构工作,以确保您从其他协作者那里获得最新的更改.