Reputation: 10296
I have a couple of branches defined for the current project where all but the master branch differ from master only by the same small set of files (less than ten).
After implementing a new feature in master I would like to replicate those changes and additions to the other branches with the least effort. What's the recommended approach here?
Upvotes: 1
Views: 367
Reputation: 2809
Normally when I fix some important thing on one branch(may even be master), and if I want the same fix to be replicated to another branch, I do git checkout my_latest_feature
and git merge --no-commit master
Never tried cherry-pick, but I think, thats the best way I guess, as cherry-pick will only merge that specific change and git merge --no-commit master
will try to get the whole tree(even other commits besides the latest fix).
I always hate any command which tampers commit history. Thats the reason why I never rebase
Update: just found this similar question: How to copy commits from one branch to another?
Upvotes: 0
Reputation: 1323973
You have three choices:
merge
: interesting if all changes of master need to be visible in one branch, but that is not always the case
cherry-pick
: to only apply certain commit to a branch
rebase
: the best solution if your branch has not yet been pushed: you replay the commit of your branch on top of master
But: in the three cases, you need to checkout the branch where you want to integrate the changes, and repeat that for each branches.
Unless your branches are made from one to another:
---o branch B1
\
----o branch B2
\
----o branch B3
In that case, you could:
git checkout B1
, git merge B2
)Upvotes: 2