简体   繁体   中英

Git use commits of master in multiple branches

I have a master branch with multiple child branches. Each child branch has a small difference compared to the master branch. I often run into the case that I update my master branch and would like the child branches take that update/commit as well. How do I accomplish this is a good clean way?

Currently I am using Gitkraken for this case, so solutions with Gitkraken are welcome as well.

If you want all master commits to be merged

git checkout feature/my-feature-branch1
git merge master

You can also consider rebasing instead of merging, for keeping the history clean.

If you want only to apply a subset of commits from master to the branches

git log # For figuring out the SHA-1 hashes you want to apply
git checkout feature/my-feature-branch1
git cherry-pick <SHA-COMMIT-1> <SHA-COMMIT-2> <SHA-COMMIT-N>

Repeat for all branches you need

您可以使用Cherry Pick来移动提交

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