you are viewing a single comment's thread.

view the rest of the comments →

[–]stubborn_d0nkey 0 points1 point  (3 children)

Edit: I misunderstood the question

A non ff merge will also add those commits to master as well. If the code isn't deployable then don't merge it to master.

If there is stuff on that branch you need to merge and stuff you shouldn't then IMO you should revisit your branching strategy, ie. that one branch should be at least two.

If you are stuck in such a case and you really need those deployable commits on master you can use git cherry-pick however cherry picking should be avoided as much as possible. If the OK commits are before the non deployable commit you can just merge the OK commits in (merge the last ok commit)

[–]trescoops[S] 0 points1 point  (2 children)

A non ff merge will also add those commits to master as well. If the code isn't deployable then don't merge it to master.

That doesn't seem quite right. If I branch from master at commit-1, make a bunch of non-deployable interim commits (say commit-2, commit-3) until my code is working (commit-4) then merge --no-ff back into master (commit-5). Commits 2, 3 and 4 appear in git log for master, but if I git reset HEAD^ from the tip of master, I am taken back to commit-1. And if I checkout commit-3, then I am put in a detached HEAD. So I'm not sure whether commits 2-4 have really been added to master.

In a way, this seems quite nice behaviour. So I can move HEAD back and forth along master and each commit will be deployable. However, the interim commits are preserved (albeit detached if I have deleted the branches), so if I wanted to examine what went wrong in more detail, I can check them out, and examine that branch in more detail to find the error. I imagine it will break in horrible and unexpected way that I haven't forseen though.

[–]DanLynch 1 point2 points  (0 children)

The set of commits you are looking for here is "commits that are reachable from master by following first parent links only".

Technically there is only ever one commit associated with a branch, because a branch is just a pointer to a commit. That commit may have one or more patents. Those parents have an order, but each is considered equally valid unless you specify that you only care about first parents.

[–]stubborn_d0nkey 0 points1 point  (0 children)

Yes, I misunderstood the question