All other branches (feature, release, hotfix, and whatever else you need) are temporary and only used as a convenience to share code with other developers and as a backup measure. They are always removed once the changes present on them land on master.
Yeah, that seems completely impractical.
Isn't it really important to be able to quickly check out the version a specific client is using? How do you deal with bugfixes to the release that don't exist in the master branch?
By checking out the tag. Presumably every version released to a client has a tag associated with it that you can use to get back to that state. The problem is that branches are a logical collection of commits, and the author is abandoning that in favor of tag soup.
Not sure what you mean by "tag soup" and "logical collection of commits". Both tags and branches are pointers to commits in Git. There can't be any difference between them, other than conceptual.
A branch's HEAD is a pointer to a commit. A branch itself is a logical collection of commits grouped together. If you add a commit on top of a tag, you have a floating commit. If you add it to the head of a branch, you're still on that branch, and the new commit is part of the collection of commits referred to by branchname. It's an organizational construct in addition to a conceptual one.
No, a branch is a pointer to a commit too. That's what it is in git. That commit can have a parent, just like a tag's commit can have a parent, thus creating your "logical collection of commits". But the branch/tag itself is just a single commit.
The difference, as you mentioned, is what happens when you create a new commit while having the branch/tag checked out. Which is why the tag solution is better.
Both are pointers to commits, but tags never change.
Once I release v1.4.5, that should NEVER change. I tag that commit and move on. If I need to make changes off of that I create a new branch starting at v1.4.5, do my development on this new branch, and when I'm done I tag the final commit as v1.4.6 and merge and delete the branch.
Both are pointers to commits, the only difference is that the commit a tag points to does not change. This means that I don't have to deal with someone making a commit on the v1.4.5 branch by accident and all of a sudden a client's 1.4.5 is different from the 1.4.5 in my repository.
I agree with your distincting that a tag is immutable and the head of a branch is mutable. However, the branch itself is the head and a bunch of extra stuff that only makes sense because there's a mutable head. A branch can track upstream branches on remotes. If you're on master, and you pull upstream's master, you might get 5 commits that are all "part of master" for lack of a better way to phrase that. If you fetch the tag, sure you'll get the parent commits, but I would argue that there's a conceptual difference there. Also, if you run git pull, you'll get changes to branches but you won't get tags unless you add --tags. Same for pushing. This makes logical sense, because branches change all the time and tags don't; branches are primarily used for collaboration and tags aren't. Branches, in addition to having a mutable head, have a bunch of metadata that makes them different from tags, and git treats them differently, so there's a practical difference as well as conceptual. I'm not arguing that a branch "points" to more than one commit so much as I'm arguing that git treats them differently, that there are implications to that difference in mutability that are the core difference between a branch and a tag.
Which is why the tag solution is better.
To address the other half of your comment, I'm obviously not suggesting that one abandon the concept of tags altogether. They can be useful precisely because of their immutability as you clearly spell out. But just because they fulfill a role doesn't mean there's no value in not also having a branch there. I am suggesting that if you're going to essentially implement a branch using tags, you don't really gain much from not actually having a branch with them, and you lose all of that collaborative metadata and interface niceties I was talking about. To be clear, I'm also not suggesting a v1.4.5 branch. Depending on circumstance perhaps a v1 branch, or a v1.4 branch, and commits on it could be tagged v1.4.5 etc. It makes sense for the latest version of v1.4 to be mutable because you're eventually going to make a v1.4.6, a new version of the v1.4 line. OP has made a clear argument for why he would choose to not include a v1.4 branch, but I believe having one has more pros than cons. Again, that's just my opinion based on the experiences I've had using GitFlow and variations for the last seven years or so.
But yes, I do understand the difference between branches, branch heads, and tags, thanks :) have an upvote.
You can create a v1.4.x branch to track the latest tag. So instead of picking the latest among v1.4.0 v1.4.1 v1.4.2 v1.4.3 v1.4.4 v1.4.5 you get it completely automatized and foolproof.
People accidentally commit to the wrong branches way too often for me to call any system "foolproof"...calling a system "foolproof" is just asking for the world to invent a better fool =)
9
u/BezierPatch Jun 19 '15
Yeah, that seems completely impractical.
Isn't it really important to be able to quickly check out the version a specific client is using? How do you deal with bugfixes to the release that don't exist in the master branch?