Live data from Hacker News

Some bad Git situations and how I got myself out of them

ohshitgit.com

171–180 of 352 posts

Re: Some bad Git situations and how I got myself out of them

#171
post #80

The last addendum reminds me of this inexorably relevant xkcd entry: https://xkcd.com/1597/

It's funny because it's true. I've never bothered with all these complicated commands which leave me nervous. I rather just wipe the whole thing and reclone it. Then I know what I get.

Re: Some bad Git situations and how I got myself out of them

#172

I can't believe no one has responded yet with "use a GUI". After gaining a basic understanding of how branches and merges work, and I do mean basic , I've never been able to screw up a local repo with a GUI client enough that I haven't been able to recover with the same GUI tools. I understand that people need to know how to use their tools, but for git most people can get away with the very basic usage that GUIs pro…

I am surprised that somebody claim that has messed up a git repo. Since I started using git, I haven't ever messed up with my code.

I always use git on the command line. Regarding GUI tools I like to avoid them, for me is too much noise. People get lost most of the time because they don't know what the tool is doing. After all is just one more layer on top of git core tool per se (aka, what you have in command line).

Re: Some bad Git situations and how I got myself out of them

#173
post #147

Another option is to use Mercurial with hg-git to GitHub for network effects. I've been doing that for a while for dropbear ssh, it does hit occasional problems but is overall more pleasant than straight git.

I've had problems with tags. What else have caused you problems?

Re: Some bad Git situations and how I got myself out of them

#175
post #109

I don't know if this post was intended as humour or a way to vent out some frustration but in my experience, this path of treating git as "spell X solves problem Y" will always break down. Version control systems are an important part of the programmers toolkit and it's worth investing a little time to get the fundamentals right. Sure git is not the friendliest of beasts but what it lacks in interface, it more than m…

I think the reason you're disagreeing is that you're not looking at this from a beginner's point of view. Generally there are (roughly) three approaches depending on where you are in your journey from beginner to expert: As a beginner, you need specific, detailed, step-by-step instructions: First run X, then run Y, finally run Z, if something goes wrong along the way, follow these other steps, if that doesn't work, a…

"A lifetime" is massively exaggerated. I would argue that I know the majority of intricacies of every git command, and I've spent much less than a lifetime on this (about 2 years in reality, alongside other things, of course).

> As a beginner, you need specific, detailed, step-by-step instructions: First run X, then run Y, finally run Z, if something goes wrong along the way, follow these other steps, if that doesn't work, ask someone for help.

That's one way to do it, but it's not preferable. I would rather sit the beginner down for at least an hour and go through the basic concepts with them.

I've taught Git to a few people (mostly fellow students or colleagues) and I found that they have a much easier time when they are introduced early on to the basic concepts of Git (the commit graph, and branches/tags as pointers into the graph), they have a much easier time grasping relevant tasks like merge and rebase.

For specific questions (mostly in these "I screw up" moments), a whiteboard is also really helpful to explain them how the two or three magic commands that I tell them are actually fixing things up.

Re: Some bad Git situations and how I got myself out of them

#176
post #88

Earlier quoted context omitted.

SVN is a glorified backup - which is basically what you're saying. The SVN UI is just horrid in other dimensions, mainly the "you can't do that at all" one.

sorry... you come across as a git-sheep. (getting down-voted for it, but someone has to say it)

I'm prepared to give you a lot of examples (which other people might value differently). From the unfortunate consequences of the 'branches are files (and therefore tags are easily mutable by default and surprisingly hard to pin down)' to usual "I just committed, why does 'svn log' not show that?", to git bisect, to git clean and the stubbornness with which svn refuses to even consider implementing that.

Re: Some bad Git situations and how I got myself out of them

#177

I can't believe no one has responded yet with "use a GUI". After gaining a basic understanding of how branches and merges work, and I do mean basic , I've never been able to screw up a local repo with a GUI client enough that I haven't been able to recover with the same GUI tools. I understand that people need to know how to use their tools, but for git most people can get away with the very basic usage that GUIs pro…

Sure, it's harder to screw up. But, dang it's just so remarkably slow.

If you're used to the commands from the keyboard, where you're likely already typing from your editor...can't imagine going back to the GUI.

Re: Some bad Git situations and how I got myself out of them

#178
post #135

Earlier quoted context omitted.

Can you justify git>subversion or are you just following the sheep? Not saying I disagree... but subversion is still king in the corporate-engineering companies and it tends to work well in those types of setups. Just beware of having unjustified-opinions. SVN may not be trendy... but neither will git in a few years time. BTW: Mercurial still beats them all.

>subversion is still king in the corporate-engineering companies and it tends to work well in those types of setups. For some values of "work". We're using SVN at my new job, with a single trunk branch. Not having the ability to commit locally, and mess around with local branches is a pain in the ass. I found a solution though. I cloned SVN repo using git-svn and now I can make local commits like a pro, and use my be…

Yes, git-svn is probably the reason why the mutiny didn't happen yet in some departments. You can identify their users by having several SVN commits in as many seconds.

(I used git in an cvs-to-svn migration, and stayed since.)

Re: Some bad Git situations and how I got myself out of them

#179
post #173
post #147

Another option is to use Mercurial with hg-git to GitHub for network effects. I've been doing that for a while for dropbear ssh, it does hit occasional problems but is overall more pleasant than straight git.

I've had problems with tags. What else have caused you problems?

Mainly when I've merged a pull request on github, didn't pull to mercurial, then did some branching in mercurial. Eventually have always managed to sort it out, but sometimes requires a bit of push/pull fiddling.

Now you mention it my git tags are out of date...

Re: Some bad Git situations and how I got myself out of them

#180
post #146

Earlier quoted context omitted.

> ... that just happened to win the PR battle ... Chalk that up to the power of fashion. Otherwise, people would use an SCM that doesn't destroy their work in the blink of an eye and actually has an API that deserves the name.

The only way to lose work with git is either to (a) not commit it or (b) run a garbage collection.

...and having commits that are not referenced by any branch.

And (c) lose the entire subtree the repo is in.

Post reply on HN