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)
我很确定我没有遵循正确的步骤.那么,"正确的方式"是什么:
和:
相关信息:
Sha*_*baz 13
您不需要创建不同的存储库.你应该学习什么,你可能会喜欢git是与分支机构合作是多么容易.所以第1步:
现在我们都已经确定了,这就是我们的想法.假设您目前只master在您的bitbucket上:
克隆存储库:
$ git clone git@bitbucket.org:user/example.com.git
$ cd example.com
Run Code Online (Sandbox Code Playgroud)创建你的分支:
$ git branch dev
$ git branch staging
Run Code Online (Sandbox Code Playgroud)让其他人知道这些分支:
$ git push origin dev
$ git push origin staging
Run Code Online (Sandbox Code Playgroud)开工!
$ 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
Run Code Online (Sandbox Code Playgroud)注意:上面的示例是一个简单的分支实验合并,可能不会反映您的教程的确切工作流程.
简而言之,您没有不同的存储库,而是在单个存储库中具有分支.在这些分支之间,您可以根据需要合并您喜欢的任何工作流程.您可以拥有未推送到原点的其他分支,因此它们对其他分支是隐藏的.当然,您还应该经常git fetch/ git merge希望每个分支机构工作,以确保您从其他协作者那里获得最新的更改.
| 归档时间: |
|
| 查看次数: |
5611 次 |
| 最近记录: |