[英]Git workflow (Dev>Staging>Live) basic technical questions
我对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
初始存储库
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 .
一些关于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
当事情准备好发布新版本时
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
我很确定我没有遵循正确的步骤。 那么,“正确的方式”是什么:
和:
相关信息:
您不需要创建不同的存储库。 你应该学习什么,你可能会喜欢git是与分支机构合作是多么容易。 所以第1步:
现在我们都已经确定了,这就是我们的想法。 假设你目前只master
了你的bitbucket:
克隆存储库:
$ 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
注意:上面的示例是一个简单的分支实验合并,可能不会反映您的教程的确切工作流程。
简而言之,您没有不同的存储库,而是在单个存储库中具有分支。 在这些分支之间,您可以根据需要合并您喜欢的任何工作流程。 您可以拥有未推送到原点的其他分支,因此它们对其他分支是隐藏的。 您当然也应该git fetch
/ git merge
每次经常git merge
您想要处理的分支,以确保您从其他协作者那里获得最新的更改。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.