Junio C Hamano <gitster@xxxxxxxxx> writes: >> I’m a git user, and recently I’ve noticed there’re some differences between >> “$ git format-patch –n” and “$ git format-patch HEAD~n”. According to the >> documentation: “-<n> Prepare patches from the topmost <n> commits.” > > Correct. However, HEAD~n will prepare patches for commits that are > not ancestor of HEAD~n. > > And there may well be a lot more than n such commits, unless you are > working on a strictly linear history. Every once in a while, a illustration would help new folks. In this history (as always, the time and ancestry topology flows from left to right): E-------F---G / / A---B---C---D imagine that your HEAD is at commit G. - G~1 == G^ == F - G~2 == G^^ == E (suppose F is a merge of D made on E) - G~3 == G^^^ == B - G~4 == G^^^^ == A so "git format-patch HEAD~4" will give you B, C, D, E and G (five commits). Asking for "git format-patch -n 4" does not make much sense in a history like this, but it will give you G, D, C, E and at that point you have seen 4 commits, so you won't get B. Note that if F were a merge of E made on D, that would make - G~2 == G^^ == D - G~3 == G^^^ == C - G~4 == G^^^^ == B And "git format-patch HEAD~4" will give you C, D, E and G (four commits). -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html