aspnetdeveloper
aspnetdeveloper

Reputation: 647

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?

Upvotes: 12

Views: 15324

Answers (2)

mwarsco
mwarsco

Reputation: 541

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

Upvotes: 16

DaveWeber
DaveWeber

Reputation: 141

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

Upvotes: 4

Related Questions