简体   繁体   English

如何使用GIT在任何新分支上获取所有分支内容

[英]How to get all branches content on any new branch using GIT

I know this question is asked many times on SO. 我知道这个问题已经被问过很多次了。

I just wanted to get proper way of branching and fixing mine. 我只是想获得正确的分支和修复方式。

My working methodology on Git branching is: 我在Git分支上的工作方法是:

  1. Checkout to master 结帐至主人
  2. Take pull of all branches one by one on master ( if there are any latest branches that are not merged on master yet but existed on remote ) Checkout new branch from master. 在主服务器上一一拉动所有分支(如果有任何最新的分支尚未在主服务器上合并但在远程存在),请从主服务器签出新分支。
  3. Work on that branch 在那个分支上工作
  4. Push to Git 推到Git
  5. Now again checkout to master 现在再次结帐给主人
  6. And take pull again 并再次拉
  7. And then checkout to new branch again. 然后再次签出到新分支。
  8. All above. 以上全部。

So, I know this is not the right way to doing this Git branching. 因此,我知道这不是执行此Git分支的正确方法。

I always stumbled myself on these branching and sometime I lost work too due to wrong branching and push pull. 我总是在这些分支上迷迷糊糊,有时我会因为错误的分支和推拉而失去工作。

Can anybody explain the write way of doing this branching properly? 谁能解释正确执行此分支的写入方式? Including best practices as well. 包括最佳做法。 So, I will follow those procedures for my current project. 因此,我将在当前项目中遵循这些步骤。

Also, my main concern is having latest code all the time on any branch ( I think master as we checkout new branch from that branch ) 另外,我主要关心的是始终在任何分支上都拥有最新代码(我认为是主人,因为我们从该分支签出新分支)

I'll try to explain one way to work with branches. 我将尝试解释使用分支的一种方法。 You can find other in the internet and from my point of view there is not a perfect one. 您可以在互联网上找到其他网站,但从我的角度来看,这并不是一个完美的网站。

在此处输入图片说明

In this image, you have your master branch. 在此图像中,您拥有master分支。 The one that has the working code that is on production. 具有正在生产的工作代码的代码。

From Master branch, you have a develop branch. 在Master分支中,您有一个develop分支。 This branch will have your most recent code, with features that your testing and building. 该分支将包含您的最新代码以及测试和构建的功能。

From Develop branch, you have all your feature branches. 在Develop分支中,您拥有所有feature分支。 The ones that you'll start new features 您将启动的新功能

So, the workflow would be: "Oh, I have an idea off feature to add to this project." 因此,工作流程将是:“哦,我有个想法要添加到该项目中。”

  • Create a branch from develop with the name of 'feature idea' develop创建分支,名称为'feature idea'
  • Develop the feature in that branch 在该分支中开发功能
  • Merge to develop to test 合并到develop测试
  • "Oh, another idea!" “哦,另一个主意!”
  • Create another branch from develop named 'ideia 2' develop创建另一个名为'ideia 2'分支
  • Develop in that branch 在那个分支发展
  • Merge to develop 合并develop
  • test test test 测试测试
  • Merge to master 合并master

This way you'll always have a working code at master and a 'beta' version at develop 这样,你将永远有在工作代码master和“测试”版本的develop

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM