5 ms·
Thus git checkout -b makes perfect sense. Does it? Pull and then merge is a common operation; it gets a top-level command. Create a new branch from the one I'm
by ubernostrum 14y ago
Thus git checkout -b makes perfect sense.
Does it? Pull and then merge is a common operation; it gets a top-level command. Create a new branch from the one I'm working on and check it out is a common operation; it gets a flag on an existing command. What logical, coherent process decides that in each case?
Branches have only one meaning in git!
Hence the "forces end users to do so". There are two very common ways people use branches: one is as a temporary place to do a quick bugfix, the other is as a long-lived place to do a major rewrite or refactoring. With respect to the history of the codebase, these have very different implications, but semantically are the same type of thing in git.
To pick on Subversion: when you had a long-lived branch in SVN, sooner or later you'd merge it back into the mainline... and then what happens? You want someone to be able to look at the repository and see that something major happened here and easily watch the progress, but you also want a way to say "this is done and merged". This required inventing a convention to indicate that -- in SVN, typically the finished branches would go in an "attic" directory.
In git you face the same problem: making a temporary branch, doing the work, merging and then deleting the branch is what you're supposed to do in git. But for those long-lived major branches, you need to invent a convention (commonly, tagging the merge point) to indicate that they're done.
I mentioned Mercurial because it has two different concepts for these things: the ephemeral deleted-once-it's-done line is a bookmark (which is pretty much exactly equivalent to a git branch, in that it's a named head that moves as you commit), and the long-lived major branch is... a branch. Which has additional semantics to indicate things like being finished.
This means that in Mercurial you don't have to invent and re-invent ad-hoc conventions to handle common development patterns, while in git you do.
Can't gitk do this?
Every time I say I want to see two branches side-by-side without invoking the VCS, someone says "well, here's a tool that invokes the VCS to do that!" Which shows a lack of reading comprehension.
Some folks need to branch differently than others.
Sure, but why isn't there a clearly-documented "most projects will get along fine with this" workflow? Or, rather, why are there dozens of them? We've had VCS tools for long enough that the best practices for common cases are out there.
The github workflow might be a little tricky, but as has been pointed out there are other workflows possible in git.
Oh, there are. But git + GitHub has been relentlessly hyped as an Oatmeal-ish fantasy of unicorns farting rainbows onto a field of lollipops, so that's how people actually end up using it, and so it's valid to mention that it's a more complex workflow for contributors since it is a very common case and becoming more common.
- chris_wot 14y agoEvery time I say I want to see two branches side-by-side without invoking the VCS, someone says "well, here's a tool that invokes the VCS to do that!" Which shows a lack of reading comprehension. I'm guessing you check out a branch to a particular directory, and another branch to a different directory, then do a compare? You could create a directory, stash you uncommitted files, then checkout the branch ad do a recursive copy to the directory you want to do the compare in. Then rinse and repeat for the next branch. After this checkout the original branch you were working in and retrieve the stash. You could easily script this.
- ubernostrum 14y agoI'm not necessarily asking for solutions at this point; I'm asking why the "solutions" involve jumping through so many hoops to work around the VCS in order to do something incredibly common.
- pydave 14y agoIsn't this is the same as subversion: svn co remote_repo_path/branches/bugfix bugfix git clone -b bugfix ./local_repo_path bugfix It could be simpler if you removed the trailing target folder name (but git would name the checkout according to the repo name, instead of the branch name).