简体   繁体   中英

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?

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

您可以使用git cherry-pick将分支添加到您的UAT分支。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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