Live data from Hacker News

High-Level Problems with Git and How to Fix Them

gregoryszorc.com

121–130 of 294 posts

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

#121
post #7

Earlier quoted context omitted.

Git is over complicated for most people’s use cases, but I wouldn’t give up the fast branching and the rebasing features.

GIt is only as complicated as you make it. You don't have to use all the features :)

No. That would be like handing a professional compound bow [0] to a newbie instead of a simple one [1]. The note "only as complicated as you make it" would be quite sarcastic in this case.

[0] https://outdoorsexperienceonline.files.wordpress.com/2013/07... [1] https://www.archery360.com/wp-content/uploads/2016/05/tradit...

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

#122
post #118

Earlier quoted context omitted.

I don't like that doing so frequently litters your personal repository list with forks. Would be nicer if they allowed arbitrary users to push to branches like `incoming/ / ` in the original repo.

Isn't that up to the repository maintainer whether they allow pushes from other people? And sure, it litters your list with forks, but you can remove them as soon as the PR is merged. And that's the case for pretty much anything you contribute to (unless you can push there, of course).

No, there is no process in Github to allow everyone to push to a certain branch (or branches matching some regex). Github forces people without collaborator rights to use forks.

I've seen this lead to confusion where people fork a repo and send PRs even though they have contributor rights, because they didn't understand the difference. As an extreme example: https://github.com/flystack/misty/pull/101 - This is a repo with only one person with write access [1]. Yet this same person only commits to their private fork of this repo and sends himself PRs that he then immediately merges. I don't mean to blame the developer, only the Github UX.

[1] It says "6 contributors" on the mainpage of the repo, but four of these are from my team and we definitely don't have write access.

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

#123
While many of these criticisms are valid, they seem to be written from the point of view of a user that doesn't really want control over their versions, they just want versions.

I'd suggest that there are other tools for this, such as a properly configured ZFS setup which are atomic beyond most users widest dreams (especially if all the versions of a vim .swp file are retained).

If you just want versions, yes, git gets in your way, because git is about control. Yes if you have all those versions you could go back and 'squash' them into a commit, but can you imagine trying to bisect those to find a bug?!

Somehow I also get the feeling that this perspective is similar to that of a friend who really didn't like the idea of pulling, and that he should just be able to push to the remote repository. A seeming lack of awareness of the collaborative side of version control and development.

Git isn't just about control, it is also about providing additional provenance information and context needed in order to understand what code does and the reasons why changes were made. Sometimes in order to get there we have a bunch of low intention commits that we use to checkpoint, and let's be honest, how many have created commits that put a tree in a broken state? I know I have.

The bit about making the documentation more consistent in its use of vocabulary seems like something that will have a couple of pull requests by the morning.

tl;dr If you want versions use ZFS if you want control and communication use git. Talking defaults is always a good exercise. with and EDIT: show work would be amazing ...

edit2: I just don't see the workspaces model passing the bag of dicks test. I want to code, I don't want to have to become a community moderator and clean up people committing all sorts of crap to my project and on the other side I just wan't to code and not have to deal with the bags of dicks who are going to gate keep their projects. There are just too many social edge cases and the differences are mostly just semantic (iirc the way github implements forks is basically as workspaces anyway...). That said, I would really like it to be possible to have pull requests be part of the repo history instead of, say, the listserv.

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

#124

The general sentiment of this article is in things like: > A commit message is already too annoying for many users! So because your ass is just lazy another guy a few months down the road has to suffer (in this case decipher what it is you wanted to do with your changes)? Put some damn effort in, we have enough crapware already, we don't need to add more just because you were 'annoyed by having to document changes'.…

> The general sentiment of this article is in things like:

> > A commit message is already too annoying for many users!

You have misrepresented the article. It actually says:

> [Commit messages] can be annoying. But we generally accept that as the price you pay for version control: that commit message has value to others (or even your future self).

Maybe you misunderstood "generally accept"; it could be taken to mean "this is what people normally think (but actually they're wrong)". But it's clear from the context he doesn't mean that: it's saying that commit messages really are worth the effort (but it's OK to admit that they do take some effort). It's just context for contrast against saying that a separate staging step is not (always/by default) worth the effort.

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

#125
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…

Some useful commands I'd use in scenarios like this are:

  git add -p # select what to add to the staging area
  git reset -p # deselect chunks that I decided I don't want anymore
  git stash # saves your working state in a temporary commit (not in your branch)
  git stash pop # restores the working state from the last git stash command and drops the temporary commit
  git rebase -i $start_point # where $start_point is either a branch or some commit in your branch history. -i means interactive, which allows you to reorder/edit/reword/squash commits
  git checkout -b $newbranch $start_point # you can make a new branch at any commit in history, so if you decide to reorder your commits, then declare and older commit as a branch and get it merged first, that's fine. $start_point is optional, if unspecified the current HEAD commit is used.
For your specific example, with a staged partial commit on branch idea-1, I would:

  git commit -m 'WIP idea 1'
  git checkout -b idea-2 HEAD~1 # makes a new branch at the parent of the HEAD commit
  git add -p # pull in the desired changes
  git commit -m 'idea2 implementation'
  git checkout idea-1
  git add -p # stage the rest of the changes
  git commit --amend
  git rebase idea2 # if idea 1 depends on idea 2
I do wish git had some notion of sub-commits with their own messages, and a better UX for cleaning up a set of commits before merging them.

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

#126
post #16

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…

Personally, the problems I have with git are related to the fact that none of my coworkers use git. If I mess up my repo I don't have anyone to look for. The experience with mercurial is exactly the opposite. I never needed to look for "experts" to solve a problem in mercurial. hg help is all I needed. Consistent UX and safe and powerful VCS is all we need.

> I never needed to look for "experts" to solve a problem in mercurial. hg help is all I needed.

Git has good documentation too. As long as we're doing personal experience, here's mine: I learned git from `git help` too (well, `git --help` and `git --help`), and I never needed to look for a git expert in my team for advanced operations; I did have to be one for others quite a few times , but when it wasn't an immediate, pressing concern I could just point to the appropriate manual.

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

#127
post #47

Earlier quoted context omitted.

Stashes should cover your first scenario; put those changes (both staged and unstaged, optionally also untracked files) in a bag and re-apply them when you are back from your short expedition: https://git-scm.com/docs/git-stash To clean up outgoing changes, you can run an interactive rebase of the current branch onto its remote tracking counterpart. This will list all affected commits in a text editor, and allows you…

Problem with stashing is that you then need to redo the work of staging afterward.

you can --keep-index to avoid stashing it, and then make an additional stash. If you have modifications within the same file it'll complain about conflicts though, so on the second sash you'll have to `git stash show -p | git apply -R` and then drop the stash, which is super clunky.

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

#128
post #82

Earlier quoted context omitted.

Just keep a copy of the `.git` dir before you try the complex operation. If you screw it up, restore it back and voila!

No. This does not safeguard any uncommitted files.

Leaving any files uncommitted before a complex operation in git is a really bad idea (make a temporary commit if necessary). It's almost impossible to completely lose committed data, but pretty easy to destroy uncommitted data.

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

#129
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 try to keep my git workflow simple," and yet I see 'git rebase' but no 'git merge' in that list.

`rebase` is simpler than `merge` in larger teams/projects, as the history will be much cleaner.

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

#130
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.

My problem with the staging area is it produces commits which never "exist" (that is, that code was probably never compiled/tested in isolation).

I'd be happier if the staging area was handled at the filesystem level, give me a directory which at all times contains the staging area, so I can test it.

Post reply on HN