Live data from Hacker News

Oh Shit, Git

ohshitgit.com

91–100 of 237 posts

Re: Oh Shit, Git

#91

Another useful thing if you need to backdate commits for whatever reason are the GIT_AUTHOR_DATE and the GIT_COMMITTER_DATE environment variables, upon executing git-commit they'll override these fields in the commit to whatever date, time and timezone you specify. I use this sometimes when I'm making some previously private work public, and am redoing the commit history to make more logical sense to others who may r…

> I had three separate but related git repos that I needed to merge, so I created a new repo with separate branches to hold each repo

Similar story here: at a previous job we had a monorepo with a Rails app and Rails engines extending its appearance and behaviour and per customer.

At some point the architecture became problematic and we moved towards a shell app, a core engine, and extension engines depending on the core.

We refactored code to that end, and "forked" the original monorepo into multiple clones, one per component, then stripping the other components in each one, ending up with 1:1 repo/gem/component. This worked for a while, easing a lot of issues we had previously, allowing for proper dependency expression, independent development and releases... Everything was great and we lived happily ever after.

Then much later we hit a snag (I can't exactly recall what that snag was, IIRC it was not technical but organisational). So we looked at options and decided to merge into one single repo again. To that end we could do a big code drop, starting afresh, but (again I can't recall why) there was a need/requirement to keep at least some git history.

But at that point, "some" ends up ~== "all". So I devised a plan.

I git init'd a blank repo, added each one of the repos as separate remotes, and fetched each of them. Thus all git objects of all these repos were present. Then I checked out each one of these remote's master as a separate branch, created a subdirectory with the component name, moved every file for that checkout into that directory, and committed that. This way a) each project could live separately in the new monorepo and b) there would be no conflict for a merge.

Then came time for the merge. Two options: a) perform N merges subsequently or b) perform an octopus merge. a) just felt wrong and ugly, so I decided to try if I could work b) out, but I ended up not being able to achieve that with porcelain commands as git was being too smart and attempted to look into the history for some reason I can't recall which produced senseless conflicts (IIRC git merge isn't entirely assymetric)

So, since merge commits are merely commits with more than one parent I figured out I may be able to do that with plumbing commands instead. So the steps were:

- for each branch, check out content (but without moving the current HEAD, so, actually, export the git tree corresponding to a specific ref/sha)

- add all that to the index

- create a merge commit object with each branch's sha as parent

And it Just Worked, with the bonus that since up til the commit where we forked, each branch had common parents that were untouched, and commit history properly zipping up, by git's design, which is really a DAG of commit objects.

Re: Oh Shit, Git

#92
post #47

I think the steps under https://ohshitgit.com/#accidental-commit-master are wrong: it reverts the commit on the new branch -NOT on the master. This is because git branch auto checks out the new branch. You need to do git branch NEWBRANCH git checkout master git revert —hard HEAD^ If you want to continue working on the new branch you do git checkout NEWBRANCH

>The command’s second form creates a new branch head named which points to the current HEAD, or if given. [...] Note that this will create the new branch, but it will not switch the working tree to it; use "git switch " to switch to the new branch.

Source: git branch --help

Re: Oh Shit, Git

#93
post #4

Git is a reminder why even the best minds in software development sometimes really should talk to UX/UI people.

Git was built with a very specific use case and aimed at an extraordinarily technical subset of users. It dominated the world despite the UX flaws, which suggests they really aren't that bad.

I've worked with CVS, Subversion, Bazaar, Visual SourceSave, Team Foundation Version Control, Mercurial and Git.

The worst systems are the Microsoft ones, but the one with the most complex interface is definitely Git.

I would argue it won because of github. I'm using Git because of that, but still prefer Mercurial in every way.

Re: Oh Shit, Git

#96

Earlier quoted context omitted.

Learning the underlying model behind git is well worth the effort. For me watching Steve Smith's talk - Knowledge is Power: Getting out of Trouble by Understanding Git - was a lightbulb moment. Here's a 2019 presentation of that talk. https://www.youtube.com/watch?v=fHLcZGi3yMQ

I think this is what can confuse people. We have to face the facts that not everyone will need or be able to grok all of what goes on in git and what makes the car go forward. We can all drive that car still! Take the recursive merging stuff around minute 39. Do I need to know why git's model for merging is so much better and how it works its magic? I don't think so. It's an implementation detail. Do I need to know h…

To a large extent, yes. But when you find yourself stopped at a red light on a steep upgrade, and some idiot behind you decides to wait for the light three inches from your back bumper, things will go better when the light turns green if you have a decent mental model of the physical mechanism of the clutch. Sometimes you want to let those abstractions leak a bit.

Re: Oh Shit, Git

#97
post #70

Earlier quoted context omitted.

> for knowingly setting up ill-conceived software to go viral I doubt that was the intention. Linux just needed a versioning system tailored to its needs, and that's exactly what Git is. Can't blame its creators that other people used it for scenarios it wasn't built for.

Right, you are the cop-out I am complaining about. Linus is the premier figurehead of the premier open-source project. When a build tool he made for that project goes viral it isn't an accident. If it was anybody else's pet versioning control system would we even be talking about it?

There is no cop-out. I use git, with pleasure and gratitude, for everything, because of its excellent design and performance. It appeals to my intuition, and I like the interface. You are entitled to your opinion, but not to confuse it with objective reality.

Re: Oh Shit, Git

#98

Earlier quoted context omitted.

I think this is what can confuse people. We have to face the facts that not everyone will need or be able to grok all of what goes on in git and what makes the car go forward. We can all drive that car still! Take the recursive merging stuff around minute 39. Do I need to know why git's model for merging is so much better and how it works its magic? I don't think so. It's an implementation detail. Do I need to know h…

To a large extent, yes. But when you find yourself stopped at a red light on a steep upgrade, and some idiot behind you decides to wait for the light three inches from your back bumper, things will go better when the light turns green if you have a decent mental model of the physical mechanism of the clutch. Sometimes you want to let those abstractions leak a bit.

They'll go even better for you if you just have good skill with the clutch - regardless of how it works or not.

Re: Oh Shit, Git

#99
post #88

Earlier quoted context omitted.

Git has been successful despite the UI, not because of it.

Can you substantiate your opinion? It's open source, so why hasn't an alternate interface taken over?

Because standardization matters and the first thing to become the standard is extremely difficult to unseat.
Post reply on HN