How to create a git workflow based on splitting your current branch into two, and later picking one to PR? [closed]

I’ve create a feature branch feature/CRM-123_some_feature, where CRM-123 is the Jira ticket ID.

I’ve tried doing it one way, and made a local commit. After testing, the performance was not great, so I’ve tried a different way, changing my code significantly and retesting.

Now I want to keep this experimental branch, switch back to my earlier code, and try modifying it.

So I kind of have two branches. Later, I want to do a PR for one of them and merge back into develop.

I’m on the original feature/CRM-123_some_feature branch, but with new changes. I assume I could create a new branch, which will be based on my original one, using git checkout -b feature/CRM-123_some_feature-experiment1, and checking my updated code.

I could then checkout my first branch, and try various modifications to that, checking in the results.

When I come to merge with develop, and I merge feature/CRM-123_some_feature-experiment1, but not feature/CRM-123_some_feature, will the changes in feature/CRM-123_some_feature be missing from develop?

Or maybe I need three branches:

feature/CRM-123_some_feature
-- feature/CRM-123_some_feature-experiment1
-- feature/CRM-123_some_feature-experiment2

and need to merge one of the two experiment branches back into the original feature/CRM-123_some_feature branch and PR that, if PR’ing the experiment2 branch on its own will lose the original branches changes?

What is the simplest solution?

7

If you have made further commits on feature/CRM-123_some_feature after creating feature/CRM-123_some_feature-experiment1, then the changes introduced by those commits won’t be included when merging feature/CRM-123_some_feature-experiment1 into develop.

So, to visually represent the situation described above, the changes introduced by commits G and H won’t be merged into develop when doing a PR from feature/CRM-123_some_feature to develop.

A -- B                       develop
      
       C -- D -- G -- H      feature/CRM-123_some_feature 
             
              E ----- F      feature/CRM-123_some_feature-experiment1

But, If your situation is the following, then every change introduced by feature/CRM-123_some_feature will be brought into develop when creating a PR from feature/CRM-123_some_feature-experiment1.

A -- B                       develop
      
       C -- D                feature/CRM-123_some_feature 
             
              E -- F         feature/CRM-123_some_feature-experiment1

Keep in mind that, when you merge a branch (feature) into another branch (develop), Git first determines the set of commits to merge by going from the head of the other branch up to the merge base (the commit where the two branches have diverged). Then, applies the commits’ changes on top of the target branch.

So, in the first case, the commits that will concur to the merge will be F, E, D, C, and their changes will be applied on top of develop. Commits G and H will be excluded from the merge, because there is no path from F to B that can reach G and H (in Git commits only point to their parent(s)).

3

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật