有没有办法将beta合并到master而不添加额外的合并提交?

huangapple go评论107阅读模式
英文:

Is there a way to have beta merged into master without adding an extra merge commit?

问题

我们有一个 GitHub 存储库,其中有两个分支,main和beta。
main:生产服务器流水线,beta:测试服务器流水线。
当需要新功能时,我们创建一个feature1分支。

步骤1:

git checkout feature1
进行更改
git add .
git commit -am "创建了功能"
git push origin feature1

步骤2:

拉取请求:我们从feature1创建一个拉取请求到beta分支。
Beta流水线触发并且测试服务器一切正常。

git checkout beta
git checkout pull origin beta

步骤3:

从beta到main或从feature1到main创建另一个拉取请求。
这里GitHub会出现一个问题,即beta分支领先和/或落后于main分支。

如何避免这个问题?使用分支方法来维护生产和测试服务器是否正确?

如何通过拉取请求将更改推送到测试和生产服务器,而不会遇到领先和落后问题?

英文:

We have GitHub repository with branches 2 branches main and beta.
main: production server pipeline and beta: testing server pipeline.
When feature is required, we create a branch feature1

Step 1:

git checkout feature1
Make the changes
git add .
git commit -am "Feature is created"
git push origin feature1

Step 2:

Pull request: we create a pull request from feature1 to beta.
Beta pipeline gets triggered and all ok with testing server.

git checkout beta
git checkout pull origin beta

Step 3:

Create another pull request from beta to main or feature1 to main.
Here github creates a problem that beta branch goes 1 commit ahead and/or behind the main branch.

What is the correct flow to avoid this problem? Is a branching approach correct for maintaining production and testing servers?

How should I push changes to testing and production servers using pull requests without encountering issues with commit ahead and behind problems?

答案1

得分: -1

我按照以下方式解释了它。我维护两个分支,主分支和测试分支,它们用作生产和测试服务器的分支,具有CI/CD管道。

  1. 从主分支创建一个测试分支。
git checkout -b beta
  1. 创建一个功能分支
git checkout -b feature/branch1
  1. 一旦功能分支开发完成,在远程推送更改。
git add -A

git commit -m "创建了功能"

git push origin feature/branch1
  1. 从功能分支创建一个拉取请求到beta/testing服务器分支。批准并合并拉取请求。

  2. 一旦在beta/testing服务器上完成测试,从beta分支创建另一个拉取请求到主分支。批准并合并拉取请求。

  3. 一旦所有更改都推送到生产服务器,我们需要确保beta/testing服务器分支与主分支保持同步。

git checkout main

git pull origin main

git checkout beta

git merge main

git push -f origin beta
  1. 现在您可以在本地和远程删除功能分支
git branch -d feature/branch1

git push origin --delete feature/branch1
英文:

I figured it out as below. I am maintaining 2 branches main and beta, which serve as branches for the production and testing server with CI/CD pipeline.

  1. Create a beta branch from the main branch.

    git checkout -b beta
    
  2. Create a feature branch

     git checkout -b feature/branch1
    
  3. Once the feature branch is developed, push changes on the remote.

     git add -A   
    
     git commit -m "Feature is created"   
    
     git push origin feature/branch1
    
  4. Create a pull request from the feature branch to beta/testing server branch. Approve and merge the pull request.

  5. Once testing is completed on beta/testing server, create another pull request from beta to main. Approve and merge the pull request.

  6. Once all changes are pushed to production server, we need to make sure that beta/testing server branch stays in sync with main branch.

    git checkout main
    
    git pull origin main
    
    git checkout beta
    
    git merge main
    
    git push -f origin beta
    
  7. Now you can delete feature branch on local and remote

    git branch -d feature/branch1
    
    git push origin --delete feature/branch1
    

huangapple
  • 本文由 发表于 2023年6月8日 19:46:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/76431532.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定