问题
I have branches
v1.0
v1.1
v1.2
v1.3
v1.4 [master]
now i checkout the v1.0 and add some directory with files (db tables, stored procedures, etc)
how to merge the newly added directory with files in all branches so my head branch will be updated with that directory
回答1:
I guess you need just that particular directory and no other changes which were introduced in different branches, if that is the case then, one way which comes to my mind right now is git cherry-pick
.
Just check git log
and find out the commit id responsible for adding that new directory and everything else you need. Now checkout your other branches one by one and use
git cherry-pick <commid id>
And that particular commit will be applied to that respective branch.
回答2:
I think you need to manually merge the updated branch to rest of the branches. Just commit the directory and other files on one of the branches (say you made the commit on v1.0
)
To merge a branch (v.10 to v1.1
) you can do
Assume you are on v1.0 branch,
git checkout v1.1
git merge v1.0
回答3:
(assuming you are on branch 1.4) git push origin 1.4
git checkout 1.3 git pull --rebase origin git merge 1.4
Resolve conflicts git add conflicted-file
git commit
git push origin 1.3
Repeat this for all other branches.
来源:https://stackoverflow.com/questions/22439019/git-merge-to-all-branches