git version 1.7.5.4
I have about 5 branches. All from the same initial branch.
I want to merge 2 branches together. say, branch1 and branch2. These branches have
I'm assuming that you really do wish to merge the whole branch, rather than just cherry-picking the odd commit. Also, what I'm saying below is heavily based on this very helpful blog post by Junio C. Hamano, the git maintainer, which I would strongly recommend reading if you want to know more about the philosophy of branching.
Unfortunately, there isn't really enough information in your question to give sound advice about this, because the question depends critically on the purpose of each branch. In one common scenario, for example, one might have a master
branch that one should always be able to generate a stable release from. When someone wants to add a new feature to the software, they might create a topic branch from master called awesome-feature
which they work on, possibly rebase, test thoroughly, and so on. When everyone is happy with that branch, it then only makes sense to merge awesome-feature
into master
, not the other way round. (The other way round would mean, approximately, that everything in master helps to implement the "awesome feature" that the topic branch is for.) You can only tell which way round is right, however, because we know the purpose of each branch.
Branching and merging is so easy in git that it supports many different workflows, from highly structured, to rather simpler, to totally unstructured. By "totally unstructured", I mean that there are several different branches of development, and people merge between them in whatever ways seem to include the features they want in a particular branch - if you're in such a situation, where there's no clearly defined purpose for each branch, it might not matter whether you merge branch1
into branch2
or the other way round. However, I find it much more helpful to have a clearer purpose for each branch, in which case the way you merge two branches does matter.