Live data from Hacker News

High-Level Problems with Git and How to Fix Them

gregoryszorc.com

261–270 of 294 posts

Re: High-Level Problems with Git and How to Fix Them

#261

One personal anecdote: In a decade of using Mercurial, I've managed to get a repository in such a confused state that I had to blow it up and start from scratch just once. In the same time, I've had to do the same for git repositories at least 5 or 6 times--and I never really used git all that much. Even nowadays, where I'm more or less forcing myself to use git [1], I'm incredibly hesitant to try any sort of complex…

> I don't think it's as appreciated that git's complexity generally discourages people from trying things out. For me, at least, the underlying model actually makes it easier to try things out. As long as my work is in commits and I have refs that point to those commits, I can be pretty sure that I'm not going to lose anything. I also take a fair amount of comfort in the fact that (unlike, say, SVN), any remote actio…

I agree.

I want a VCS that does NOT try to hide how it works from me.

I love that git gives me a) a bag of commits forming one or more rooted trees, b) symbolic names for commits/branches that resolve to individual commits in that bag.

That's such a simple model.

Remotes. Commits. Branches/tags. That's it.

Merging and rebasing merely create new anonymous branches in the bag of commits, then move a branch name (if applicable) to point to the new HEAD. Done. Trivial.

The reflog is just a local log of actions taken, and can be used to quickly recover from missteps: just find a HEAD you want as your branch's head, and then git branch -f branch .

The index/staging area are very, very useful, mostly because of git add -e, which is extremely powerful. This lets me split up my commits usefully.

Just about everything else is stuff you can figure out as you go.

The only thing you can ever lose in git (short of doing rm -rf .git) is workspace content that you have not added to the index or committed. Stay away from git reset unless you know what you're doing with it, and all is good.

Being able to think of the state of the repo as a tree of anonymous commits, with a name resolution table for resolving branches/tags to commits, makes doing complex tasks trivial for me. I often rebase in detached head mode and nothing goes wrong; when I'm done I manually move/create a branch to the new HEAD -- I can do this because the tree-of-anon-commits model is so darned simple.

Re: High-Level Problems with Git and How to Fix Them

#262
I find this depressing.

I do think the git model is superior to Mercurial's, by far.

I also find the git commands much, much easier to use than Mercurial's, unless I stop caring about having meaningful commits.

With Mercurial I end up just committing lots of work in one go, with minimal logical splitting, and that's that. The Mercurial repos I share with others are full of useless (to me) merge commits because no one can bother rebasing as rebasing is not as easy on Mercurial.

With git I can spend the effort of making clean, logical commits and rebasing so that no one need see pointless internal-to-my-way-of-working commits. I can do this because git does not hide its internals from me. I know git is a pile of anonymous commits that form trees, with branches and tags as symbolic names that resolve to specific commits in the pile.

See https://news.ycombinator.com/item?id=15910094 in this same thread for more on how the git model is natural.

Re: High-Level Problems with Git and How to Fix Them

#263

Earlier quoted context omitted.

Does anyone who's downvoting this comment care to explain why?

I did not downvote the parent comment but I find > Git has good documentation too. hilarious. Git has a sprawling mess of disorganised man pages. I find calling that "good documentation" insulting to people who care about documenting things.

https://git-scm.com/docs

Re: High-Level Problems with Git and How to Fix Them

#264
post #22

If you requested save in your favorite GUI application, text editor, etc and it popped open a select the changes you would like to save dialog, you would rightly think just save all my changes already, dammit I'm sympathetic to what this is asking, but I have to feel that this would lead to much better practices for many people. I'd wager a ton of folks would be more "why in the world does it think I changed that?" t…

There's three ways to deal with the git index/staging area:

- always commit everything, merge/push that (Mercurial style)

- always commit everything, then eventually do a rebase where you merge/split commits into logical units

- always git add -e then commit logical units

I do mostly the latter, but since I don't usually write code the way I want it in the end before pushing, I almost always have to go back and rebase to reorder, merge, and/or split commits prior to pushing.

Like you, I'm sympathetic to the idea of "save everything", and I emphatically agree that it's fantastic that you get to save just the changes you want because it allows one to produce minimal and logical commits.

I suspect that the author of TFA does not produce nice, clean, logical, and minimal commits. Instead I bet their upstream is full of merge commits and the merged branches are full of huge commits with lots of unrelated changes, and/or full of "fix a typo" commits that should never appear in upstream histories.

Using a VCS effectively to create clean, useful history upstream is hard, and some VCSes make it harder than others. Mercurial (and Fossil, and...) make it supremely difficult. Git makes it easy (though one does have a bit of a learning curve to get there).

Ironically, all the Merkle hash tree VCSes are git-like under the covers: there's a bag of commits, and some sort of branch name resolution. "Heavy-duty branches", like Mercurial's, are extremely confusing -- I never know how to recover from having multiple tips, and I don't even understand why that's at all possible. Whereas "light-weight" branching (like Mercurial's bookmarks, which still aren't reliable, or like git's branches, which are) is much much simpler -- even Mercurial's community gets this, though they still shy away from light-weight branches for some reason that I still don't understand. Fossil is exactly like git under the covers, except far, FAR superior to git in that it's relational -- Fossil is easily the best VCS ever in terms of implementation. But Fossil's dogma is highly opinionated and Mercurial-like: it has light-weight branches, but the UI is merge-happy like Mercurial's, and there's no rebasing (there's basic cherry-picking functionality, which of course is always the basis of rebasing, but that's it).

I really don't want a Merkle hash tree VCS to hide its tree nature from me.

Re: High-Level Problems with Git and How to Fix Them

#265

Earlier quoted context omitted.

I think people generally get side-tracked by focusing too much on the staging area. It's a red herring in my opinion. I barely notice that it's there, and I do the crafting-the-public-changelog thing on an almost daily basis. I recommend learning about the combination of `git gui` (including its amend option), `git rebase -i`, and `git commit --squash=/--fixup=` (and don't forget to set `git config --global rebase.au…

Resorting to rebase is a pretty heavy price to pay though.

From my experience, there's no such a heavy price as long as you don't rebase what you already shared with others.

Re: High-Level Problems with Git and How to Fix Them

#266
post #12

I'm surprisedly the staging-area hate. Does it really violate peoples' assumptions? I like the ability to make a big, complex change and checkpoint stable portions (subsets) of the work as I go.

Coming from someone who learned hg well before git, and who's now being more or less forced to use git long after developing comfortable hg workflows, the staging area feels like a half-baked implementation of what it's supposed to be doing. I'm used to thinking of commits as atomic commits--roughly, each commit is the smallest change that atomically makes sense. So you should be able to use the staging area to build…

The staging area is trivial to use effectively.

Just:

- edit files - git add -e - optionally git diff --staged (to review what will go in a commit) - optionally lather, rinse, repeat as needed - git commit

Alternatively:

- edit files - git add - git commit - lather, rinse, repeat - git rebase -i origin/master (or whatever) and reorder/squash/edit/split commits as needed

For the latter's last step, sometimes the easiest thing to do is to squash all commits when you're done, then git reset HEAD^, then apply the git add -e && git commit loop in order to break up your work into logical commits.

When done, push.

Re: High-Level Problems with Git and How to Fix Them

#267

Earlier quoted context omitted.

> I don't think it's as appreciated that git's complexity generally discourages people from trying things out. For me, at least, the underlying model actually makes it easier to try things out. As long as my work is in commits and I have refs that point to those commits, I can be pretty sure that I'm not going to lose anything. I also take a fair amount of comfort in the fact that (unlike, say, SVN), any remote actio…

I agree. I want a VCS that does NOT try to hide how it works from me. I love that git gives me a) a bag of commits forming one or more rooted trees, b) symbolic names for commits/branches that resolve to individual commits in that bag. That's such a simple model. Remotes. Commits. Branches/tags. That's it. Merging and rebasing merely create new anonymous branches in the bag of commits, then move a branch name (if app…

Now, can that be explained to a git newbie in under half an hour, to get them up and running?

IMO, the scary UI/UX of git is holding back the use of version control for a lot of digital documents beyond just source code. It needn't be this complicated.

Re: High-Level Problems with Git and How to Fix Them

#268
post #138

This is a really interesting piece that introduced a number of ideas I hadn't ever thought deeply about, particularly in the section on nameless workflow. (I do think of myself as reasonably capable with both Mercurial and Git.) If your instinctive response is to defend Git, boost Mercurial, ridicule people who can't use their tools, ridicule the tools for being unusable, or whatever -- suppress it for a while and gi…

My instinctive response is to explain why git is easier. TFA is very unfortunate. I think the author is missing out on a better experience, and their git hate isn't helping them.

Re: High-Level Problems with Git and How to Fix Them

#269
post #79

Here are the commands I use: git init git clone git checkout git commit git commit -m git commit —amend git rebase git add/rm/diff [—cached] git push git branch and a few more I can’t remember exactly. I try to keep my git workflow simple. The most complex is probably checkout abd rebase with several different branches.

I especially use:

- git add -e

- git rebase -i --autostash

- git checkout -f -- (to undo changes)

- git diff/log (of course)

- git reset HEAD^ (to undo the head commit but leave its changes extant in the workspace so I can then git add -e and commit them in logical units)

Re: High-Level Problems with Git and How to Fix Them

#270

It's clear that there will be a successor to Git some day, in the sense that Git is a successor to SVN (yes, I know Linus's viewpoints on SVN). But the successor won't be a "better Git" just like Git isn't a "better SVN". The driving features of Git's successor will be unrelated to Git UI gripes. If Git's UI gripes were important enough, people would just be using Mercurial (which has it's own quirks). The biggest pr…

That successor ought to be Fossil, by all rights. What keeps me from using Fossil is its opinionated UI.

Lots of people hate git's UI, but it let's you do all sorts of workflows. You can rebase a lot, or merge a lot, or both. With Fossil you're pretty much stuck with a merge workflow.

What makes Fossil superior to all other VCSes is that internally it is a Merkle hash tree organized relationally, with an internal SQL interface. This makes a) development of tools much easier than for any other VCS, b) much easier to write new kinds of queries and make them perform well.

Perhaps some other VCS will come along that will do what Fossil does, but with a less opinionated UI.

I understand why Fossil is opinionated: it's not meant to be a VCS to take over the world, but instead just a VCS for SQLite3 and related projects. As such its developers don't really care for any functionality that they themselves don't care for, and thus my need for rebasing, and a staging area / index, is as nothing to them. I can't blame them, really, but it would be truly fantastic if we could support rebase workflows with Fossil.

Another thing I don't like about Fossil is its approach to repo sync. I like that with git I can push/fetch individual branches/tags, some of them, or all of them. With Fossil you don't get much choice, as it's all public branches or nothing.

Power users (and I'm not saying here that Fossil's aren't) need more UI power. To appeal more widely, a VCS as to support more power users.

Post reply on HN