Git merge one branch into two other branches
Solution 1
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
Solution 2
You can use git cherry-pick to add the branch to your UAT branch.
aspnetdeveloper
Updated on June 05, 2022Comments
-
aspnetdeveloper almost 2 years
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?
-
huggie about 10 yearsSuppose there are already some prior differences between
master
andUAT
before working onFeature
. (Say there are a few commit on master that UAT doesn't have). After working onFeature
, doesgit checkout UAT, git merge Feature
merges that prior difference into UAT as well? -
huggie about 10 yearsI checked it and it did.
-
ChrisWue over 8 yearsThe problem with cherry picking is that you only have very limited visibility on what got cherry picked and what not. This can be a problem on larger branches where multiple people are working on it. Merging is a lot better in that case from my experience
-
dan carter over 4 yearsthis will merge all the changes from master into UAT!