Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git merge one branch into two other branches

How can I merge one branch in to two other branches?

So here's our scenario: We use two branches master for production and UAT for testing purposes. All local development is made on a new branch made off of Master so before starting on something, we create a branch off of master, commit and push it to origin/master. For bigger projects we use UAT for testing purposes.

I have a branch which is ready to be tested and then pushed to production. How can I move that branch to UAT so people can test it and once tested move the same branch from my local machine or from UAT to Master?

like image 392
aspnetdeveloper Avatar asked Oct 29 '13 18:10

aspnetdeveloper


2 Answers

This is exactly what git is useful for! Start your development on a branch off of master, let's call it "Feature". Then when you're ready to test, commit your changes to your feature branch and do the following:

git checkout UAT
git merge Feature

TEST TEST TEST

git checkout master
git merge Feature
git push origin master

This will get your test code into both the UAT and master branches

like image 95
mwarsco Avatar answered Sep 28 '22 09:09

mwarsco


You can use git cherry-pick to add the branch to your UAT branch.

like image 27
DaveWeber Avatar answered Sep 28 '22 09:09

DaveWeber