Live data from Hacker News

Git cheat sheet [pdf]

wizardzines.com

21–30 of 146 posts

Re: Git cheat sheet [pdf]

#21

Are there git alternatives that aren't a PITA to master before one can use them in production?

Subversion. It was made by CVS maintainers and a lot of care and thought was put into how it works and how the commands work and what the names of the commands are. Subversion is limited in being an older model of version control where there is exactly one single source of truth.

In my mind Git solves a different problem that Linus Torvalds was facing: many people working in parallel with only some of the ideas pushed upstream, but many people wanting to make changes and easily being able to move forward to the latest changes from upstream.

My extremely opinionated view is that most people should use Subversion unless they have a very complicated team structure. And that means every solo dev working by themselves should not complicate their own lives by using Git unless they are really comfortable with it already.

Re: Git cheat sheet [pdf]

#22
post #13

A couple of hidden gems: git diff --staged (shows the diff between the last commit and what you've got staged, great when what you're staging is finicky, lets you double check that you have precisely the files/hunks you intended) git log (git log, but for just commits where was touched; saves pilfering through all of git log, especially useful when the file only gets modified infrequently) Random tip: when using git…

15 years… 15 years to discover git diff --staged !

I don't consider myself a git savvy person, but the help gives output, and I think this command is used a lot

Re: Git cheat sheet [pdf]

#23
post #14
post #2

Is there a historical reason why git is needlessly complex? Seeing this cheat sheet really brings it to life.

Yes. Because git was created by Linus Torvalds specifically to enable and advance Linux kernel development. The fact it has become so widly adopted is a "happy accident" (or misery). Github I think has been widely credited with making git so common place ("free git hosting") but I don't think git is the "ideal" revision control system for many projects. Because it was made for Linus for Linus/Linux, this is why the t…

There's a C version of hg, and more recently a rust version. I can't say how much faster they are though

Re: Git cheat sheet [pdf]

#24

I didn't know about `git add -p`. Really useful! -p, --patch Interactively choose hunks of patch between the index and the work tree and add them to the index. This gives the user a chance to review the difference before adding modified contents to the index.

I always custom-select hunks of my current work to assemble into coherent commits, where possible. I find it really helps me to rearrange the work I've done in my head in such a way that if I needed to walk someone through it, I could do so by walking the commit line.

Re: Git cheat sheet [pdf]

#27
post #5
post #2

Is there a historical reason why git is needlessly complex? Seeing this cheat sheet really brings it to life.

It's not needlessly complex. The workflow it was created to support is inordinately complex, and the target market for that is highly technical, so its complexity was not the issue. Kernel developers needed to communicate to other kernel developers in a decentralized manner, and needed to work on top of each other. How do you work on a project where there are 15,000 people writing code? Git was created for this purpo…

"Needlessly" can be in the eye of the beholder, but given that Linus basically put it together to solve the problem he was trying to solve without consulting a UX team or building a product for the ages, I would be willing to place my probability bar pretty high on the design tilting towards "One person's best idea right now" over "Best design theoretically possible."

That having been said, the team is really good at engines so the software is quite good at doing what it's supposed to do.

Re: Git cheat sheet [pdf]

#28
I always find it interesting how knowledge makes it hard to comprehend the difficulties other people have. I used to barely understand git, but after a couple of years working at a company that relies on a rebase workflow, I'd like to think I largely understand how it works. Its nice to recognise pretty much every operation on this cheatsheet.

Is it common that developers still have issues with git after using it professionally for a couple of years? Admittedly, I still have trouble remembering the commands to do what I want (hello, rebase --onto A B C), though :P.

Re: Git cheat sheet [pdf]

#30

Are there git alternatives that aren't a PITA to master before one can use them in production?

A small, simple subset of git? You generally don't need all the esoteric stuff people complain about day-to-day.

Pretty much what is listed in the OP cheat sheet.

Post reply on HN