I've been attempting the branching model as described in the following article: http://nvie.com/posts/a-successful-git-branching-model/
git merge --no-ff
the branch item then resolve any merge conflictsI assumed that all merged commits from the other branch would be brought in together in order, however that does not seem the case. The following is the output of git log
:
f28e150 Merge branch 'items'
8281666 [Master] Another middle commit before merge
73d0ca9 [items] commit 2
0442978 [items] commit 1
Why are the first two commits of item branch showing before the master branch? Wouldn't it make more sense to show them together under the merge commit since thats when I merged it all with my code?
Calling the graph option: git log --graph
shows it in the correct order
* f28e150 Merge branch 'items'
|\
| * 73d0ca9 [items] commit 2
| * 0442978 [items] commit 1
* | 8281666 [Master] Another middle commit before merge
|/
The reason I want them all together is to make it easier for me to undo the entire merge
The short answer is that git log
sorts its output, and you must choose the sort order that you prefer. (It sorts because it must: parent/child relationships in a graph provide only a partial order but git log
needs to impose a total order.)
The details are described in the git log
documentation, which is very long; search for commit ordering
(the link here should take you directly to it).
The claim of "reverse chronological order" default is a bit of a lie now (it was true in older versions of Git), so the order you get by default will depend on your particular version of Git. Note that --graph
turns on --topo-order
automatically, so --topo-order
may be what you want.
Note also that you can restrict the revision walking to look only at the first parent of each merge, using --first-parent
. In this case you won't see the other branch at all. For --first-parent
to be useful, everyone who merges needs to be somewhat careful about it, so that you do not have "foxtrot merges" shoving commits over into side branches. See GIT: How can I prevent foxtrot merges in my 'master' branch?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With