4 ms·
All the examples[1] are about the index. And indeed, the index is probably a feature that should have been optional. While it's supremely useful for maintaine
by ajross 6y ago
All the examples[1] are about the index. And indeed, the index is probably a feature that should have been optional. While it's supremely useful for maintainer-side operations (splitting patches, picking out parts of them, committing only the meat of a patch and not debug code, etc...) it's really not useful for a typical new user. At all. New users would be best served by a "commit" variant that simply updated the HEAD commit in place.
[1] Actually not the last one. I couldn't figure out what they were talking about. "Only committed versions of a file can be part of a branch" -- I mean... duh? Branches are a DAG of committed trees. I don't understand what they're asking for when they complain that the working version of a file can't be part of more than one branch. It's not part of any yet!
- tsimionescu 6y agoThe problem they are talking about is that you can't checkout a new branch wothout first committing, stashing or undoing your work. In other VCS tools, including gitless apparently, your uncommitted work is also branched (usually by virtue of different branches being chekced out in different directories on disk). You can also achieve this in Git by using different working trees.
- ajross 6y agoAh, OK. And this is why I think lots of criticism like this is a little off the rails. It's too dependent on what to my eyes is just a broken mental model. I mean... branches are commits. If you want your uncommitted work to be on a branch you... commit it. There's a command for that. It's called "commit". I mean, literally "git commit -a -m WIP; git checkout $OTHER_BRANCH" is all that's required. It's even "orthogonal" per the requirements in the article.
- geofft 6y agoThis is the workflow I follow, but my experience is it's pretty high-mental-overhead in practice - Git doesn't draw a distinction between commits that I created because I'm still working on something and want to switch branches, and are therefore reasonable to modify, and commits that came from some remote source and which you want to keep intact. They're both "commits." That means you, the user, have to keep track of which is which and think about which Git operations might disturb the wrong type of commits. I'd like Git to have a mode where, say, git rebase -i won't show me published commits by default, only work-in-progress ones. (This isn't necessarily the same as "commits since the remote branch we're tracking," since it's possible to end up tracking a branch that's behind for some reason, or even in a situation like a detached HEAD where you're not tracking anything at all.) I'd also like Git to keep track of whether I'm done with a commit and ready to publish it. Usually when I commit to switch branches, it's because I'm thinking about the branch I'm switching to, so I don't want to spend the time yet to write a three-paragraph commit message about my current work. But that makes it too easy to push an incomplete commit message.
- gmueckl 6y agoWhat you describe seems to be very close to phases in Mercurial. There, the repository keeps track of whether commits were pushed to other repositories. And you can mark commits as secret, which will stop them from getting pushed out: https://www.mercurial-scm.org/wiki/Phases https://www.mercurial-scm.org/wiki/Phases
- frutiger 6y ago> commits that came from some remote source and which you want to keep intact Don’t tags satisfy that use case?
- geofft 6y agoWell, no, because Git doesn't prevent you from modifying commits pointed to by tags. It prevents you from modifying the tags themselves, which point to the original commits, but that's not relevant - if your workflow involves a lot of "git commit --amend" or 'git rebase -i", it isn't going to stop you from accidentally rebasing or reordering tagged commits. Also, I don't think I've ever seen a repo where every pushed commit is tagged, and I suspect that will make lots of git operations that look at all refs scale poorly. The use case is that if I make a branch off current master, and then I run "git commit --amend" thinking I've already run "git commit," it shouldn't let me modify that commit - whatever it might be.
- frutiger 6y ago> modifying commits pointed to by tags You can’t modify commits. They are immutable. Tagged commits are reachable so they won’t get gc’ed. > Also, I don't think I've ever seen a repo where every pushed commit is tagged Sorry, I thought we were talking about releases (aka important commits). I’ve certainly seen plenty of repos where all the releases are tagged.
- iudqnolq 6y agoI'm in the very early stages of an alternative git client. One of the ideas I've had is marking commits as "WIP". Under the hood it'd just be a prefix, but you could toggle it like a tag. By default push would ignore them. I also think you should be able to have a bunch of WIP commits at once and stage changes to any of them equally easily (fixup/rebase but easier and by default).
- gmueckl 6y agoWhen I read comments like this, I feel sad. Between the lines I always read a resignation to design choices that create unnecessary accidental complexity amd are an obvious step backwards compared to other version control systems, even ones that came before. Competing systems like Mercurial, Plastic or fossil are a simple proof by existence for this claim. Yet there is some snobbery/mysticism around git that makes any meaningful evolution in this space impossible.
- ajross 6y agoQuoted without comment: > When I read comments like this, I feel sad. Between the lines I always read a resignation to design choices that create unnecessary accidental complexity amd are an obvious step backwards compared to other version control systems, even ones that came before. Competing systems like Mercurial, Plastic or fossil are a simple proof by existence for this claim And then IMMEDIATELY: > Yet there is some snobbery/mysticism around git
- fao_ 6y ago> Competing systems like Mercurial To clone Mozilla Firefox, Mercurial requires you have more than 2 Gigabytes of RAM. Not Firefox, Mercurial. Simply because the version history is so large, it requires over 2 Gigabytes of working memory to properly interact with enough to put a current clone of the repo on your computer.
- gmueckl 6y agoAs long as we're sharing anecdotes: I've seen Mercurial used very successfully with much, much larger repositories than Firefox and I'm fully aware that Firefox is already big. I don't know how big the full repositories were, but I am assuming at least several TB. I have never seen git getting pushed that far and I have no idea how it would behave then. My guess is that it would slow down a lot, but at least not fail entirely.
- jononor 6y agoI belive the entire Windows codebase is in a git monorepo now, for some years: https://devblogs.microsoft.com/bharry/the-largest-git-repo-on-the-planet/ https://devblogs.microsoft.com/bharry/the-largest-git-repo-o...
- ajkjk 6y agoThe idea is that that mental model isn't a very useful and error-proof one. Saying "well that's the mental model" doesn't evade criticism of the mental model.
- ajross 6y agoBut it's not criticism of the mental model, it's criticism that fails to recognize there are models that fit the problem better. Again, changing a branch and preserving your work is sequence of two commands; two very obvious commands applied in the obvious way, no less. You learn what a "branch" is in git and then you don't have problem. The problem with the linked article is that it's trying to understand a "branch" to mean something like a "working area" or a "checked out directory" or something. And that's just a different mental model. And getting to the criticism in the linked article, it's a very non-orthogonal model, polluting the idea of a "working tree" (which in git just means "the filesystem contents") with weird metadata about where the files "came from".
- ajkjk 6y ago> it's criticism that fails to recognize I really don't think that's the right interpretation. This is a direct criticism of the correct mental model for Git. In essence is says "This model, although functional, is way more complex than it needs to be. Here is a simpler model that accomplishes the same goals with less confusion for beginners and experienced users alike." I don't see a great argument for the concept of un-committed changes existing at all, and the tool would be a lot easier if they didn't. My implementation would be for every local change to be immediately amended onto HEAD, and then `git commit` creates a new empty commit for subsequent changes to attach to. If you want to not include a file, exclude it. Or something like that, I haven't thought about it in detail really.
- ajross 6y ago> "This model, although functional, is way more complex than it needs to be. And I don't see how that statement is consistent with: # First Understand "branches are commits" $ git commit -a -m WIP $ git checkout $NEW_BRANCH I just don't, sorry. Trivial concept. Trivial composition of two commands you use all the time. Orthogonal. Clean. Straightforward. There are areas (c.f. the index, which I talked about upthread) where git does make excessive demands on the new learner. This is simply not one. Sorry. What the linked article wants to see is objectively a more complicated UI based on an incorrect understanding[1] of what a git branch is. [1] Which is weird, because git's idea of "working on a branch" is fundamentally unchanged from the legacy handed down from SCCS, RCS, CVS and subversion. NONE of those tools ever did this!
- zwieback 6y agoWhere I work nobody enforces which RCS to use so we have lots of SVN, lots of git and some Perforce and maybe another oddball somewhere. Even though it's ugly I'm sold on git but every time I recommend it to someone who is not used to it I tell them: "get used to the idea that you only ever have one version of your source on your PC, no concurrent branches in different directories." I know git half-heartedly supports multiple working trees but I think you're best off doing the "commit-WIP-then-branch" approach. Even stash is pretty ugly, I only use it for things like config files someone committed that I in turn would never commit (like IDE proj files, etc.)
- lowbloodsugar 6y agoWhich is, of course, bollocks, because the first thing anybody does when working on a hotfix is to create a new directory and create a new tree there. The only difference between git and perforce is that in perforce, the concept of directory<->branch is built into the system, but with git, git knows nothing about it and its all manual. Instead, git is one of the VCS that says "you can have only one working copy on disk" and when you switch branches we'll believe that you want to throw away what you were just working on. I used to think the "one directory" for everything was the way to go. In a startup around 2001, I tried ten different VCS systems, including looking for ones I'd never heard of (e.g. AccuRev), and I initially vetoed perforce because it wanted to put different branches in different folders. When all was said and done, I selected perforce for precisely that reason. But git goes further than simply not having "multiple checked out branches" as a concept. Instead, its conceptual model for why I have branches and what I want to do with them is fundamentally wrong, as this article points out.
- formerly_proven 6y ago> because the first thing anybody does when working on a hotfix is to create a new directory and create a new tree there. This doesn't make any sense, at all, in any way or form to me. Everything from build systems to IDEs is tied to were the tree is, I most certainly _don't_ want to constantly change that. > and when you switch branches we'll believe that you want to throw away what you were just working on. Switching branches checks if something would be thrown away, and will not proceed if that is the case.
- leephillips 6y ago‘New users would be best served by a "commit" variant that simply updated the HEAD commit in place.’ Isn’t this what `git commit -a` does? Or do I misunderstand?
- gmueckl 6y agoThe article already contains an eloquent critique of this option: its semantics are too broad and inflexible to cover that use case.
- sixstringtheory 6y agoHmm, I wonder if GP meant `git commit --amend` which is not the same as `git commit -a` (`git commit --all`)?
- gmueckl 6y agoAn actually sane VCS would stash your changes when switching to another branch amd restore the stash when switching back, at least by default. Git instead handles this in a way that introduces a handful of potentially data shredding gotchas.
- hctaw 6y agoI always just commit my changes and switch branches, come back and squash.
- bob1029 6y agoThis is my go-to as well. I use commit messages like "intermediate work" and then push to origin to make it clear things are in a temporary state from the outside (i.e. someone looking at exploding check builds). You can usually infer exactly what I am working on just by reading the latest commit messages on all of my branches.