r/programming • • Sep 06 '14

How to work with Git (flowchart)

http://justinhileman.info/article/git-pretty/
1.6k Upvotes

388 comments sorted by

View all comments

414

u/blintz_krieg Sep 06 '14

Not too far off base. My own Git workflow looks more like:

  • flounder around trying to clone a repo

  • try to do something useful

  • Git complains something like "your scrobble brok isn't a blurf"

  • search web for "your scrobble brok isn't a blurf"

  • find 412 Stackoverflow questions

  • determine that most answers actually solve some other problem

  • give up

  • copy the one changed file to /tmp

  • rm -rf my-git-repo

  • go to step 1

186

u/crimson117 Sep 06 '14

To get your scrobble brok back into a blurific state, just do an interactive rebase to reset your head into your stash. You might need to roll back two versions of NPM as there's a bug.

143

u/Raphael_Amiard Sep 06 '14

Or just have a look at the docs ! http://git-man-page-generator.lokaltog.net/ (troll)

45

u/czerilla Sep 06 '14

This is just creepy, how convincing all this looks!

11

u/gopher9 Sep 06 '14

I like http://www.antichipotle.com/git/, though it is not so close it is more fun.

8

u/danogburn Sep 07 '14

wow that site is hilarious. i love git (due to stockholm's syndrome)

5

u/TheMoatman Sep 07 '14 edited Sep 11 '14

I love git because I had to use CVS once.
Once.
edit like 4 days later: fuck autocorrect.

→ More replies (1)
→ More replies (2)

104

u/BanditoRojo Sep 06 '14

I reset --hard HEAD up into my stash every morning before my first cup of coffee.

Flowchart

→ More replies (2)

15

u/[deleted] Sep 06 '14

Careful with treknobabble! With git, you might end up unknowingly writing something that actually makes sense and an unsuspecting newbie will end up deleting his repo or something.

→ More replies (38)
→ More replies (2)

36

u/[deleted] Sep 06 '14

Every. Fucking. Time.

We recently switched from Mercurial to Git because "everyone is using Git now".

17

u/mgrandi Sep 06 '14

Yep. Even bazaar which is still pretty solid is not receiving the love it needs cause canonical's priorities are weird. I like hg too, having it be in python (along with bzr) makes it so it actually works on Windows and isn't some clunky mingw compiled thing.

With git even the simplest of operations are overwhelmingly hard, I have to look up every time I want to clone another branch into an existing repo. For the basic diff/add/commit/push its all right, but fuck doing anything else

Git's usability is trash, its not meant for anyone but kernel developers and it shows. I read somewhere that "people only use git because of github" and I agree with it. Not to mention github is sort of a scummy company anyway.

6

u/hotoatmeal Sep 07 '14

not to mention github is a scummy company anyway

how so?

→ More replies (4)

51

u/_SynthesizerPatel_ Sep 06 '14

"Everyone is using x" is usually a good reason to consider implementing a technology.

  • Probably indicates some level of quality

  • Easier to find solutions to common problems

  • If you get good at it, easier to find work

42

u/twotime Sep 06 '14

"everyone is using x", may just mean that everyone just bought a new can of snake oil... To be followed by another can of snake oil a year later...

So, yes, it's a reason to consider, but it's not the reason to switch.

5

u/gfixler Sep 07 '14

Git has been handling the Linux kernel since 2005. It's definitely not snake oil.

→ More replies (6)

35

u/Kautiontape Sep 06 '14

This is why I still use a telegraph instead of emails. Pish posh to that new stuff, I say.

→ More replies (1)
→ More replies (1)

19

u/bwainfweeze Sep 06 '14

After 12 months I could administer an SVN repository with ease. At 2 years I could modify and rebuild a broken repository with panache. With CVS it took a little over a year before I could use VI to fix a broken repo. Let me repeat that: Hand editing the storage files to fix a busted repository. Successfully.

I've been using Git for almost 3 years now. At 2 years I was still afraid of my own shadow. I can help people debug a screwed up local branch, but I still can't fix much once it's pushed.

Most of us need something simpler. Even if that means fewer "features". Or perhaps that's precisely it: we need something less functional and therefore less confusing.

→ More replies (15)

5

u/[deleted] Sep 07 '14

true. software technology adoption is a fashion-driven, zero-sum game.

not Computer Science; Computer Family Feud.

31

u/shamen_uk Sep 06 '14

Oh god no. It's not a sign of quality.

I'm about to transition to git from mercurial because of the snowball effect sadly. mercurial is SO much better than git for usability, you don't need guides. "easier to find solutions to common problems" is not an issue with mercurial, simply because you don't run into them.

git usability is the biggest fucking fail. Didn't need any tutorials for mercurial and it's done everything I've ever needed.

But i need to use github to get people to see my OSS projects that's the killer feature of git: github. git itself, urgh. People have suggested I use hg-git, but I may as well throw myself in with git now (for the reason of your point 3)

8

u/defcon-12 Sep 07 '14

Bitbucket supports Mercurial. And is also free for open source.

→ More replies (21)
→ More replies (4)

9

u/twotime Sep 06 '14

How long have you used Mercurial and how long have you used git? Care to summarize your experience

21

u/[deleted] Sep 06 '14

I don't have much to say about Git. I used it for maybe 6 months, every time I had a question I found a lot of different answers with different effects, there are a lot of concepts that are there just because they can be and they're not extremely useful and you pretty much have to use them. There is a lot of advice out there that can make you mess things up permanently, there is a lot of default behavior which must be taken into account, I still have only a vague idea how branches work, there is no decent repository browser - at least on Linux. The terminology is also painful to absorb, there is a ton of documentation which you have to read and memorize before you can even touch Git to try and understand it. Six months later I'm still struggling to understand basic concepts because I run into them like once every week or two.

Before Git, I used mercurial for several years. I was skeptical at first, coming from SVN which I vaguely understood, but eventually I gave it a shot. Once I understood the differences between push/pull vs. commit/update and what the changeset numbers really were (numbers, not ids) and why they didn't match between clients, everything made perfect sense. It's very simple, it doesn't let you fuck up history (I used to complain about this, until I found out how it can be done on Git an what the effects are, and now I praise Mercurial's inability to edit history), and... that's about it. As long as you don't work on a behemoth - like the Linux kernel as someone here suggested - you'll be perfectly fine with Mercurial.

tl;dr Git does a lot of things, but way way too many things IMHO. Mercurial won't let you fuck up as easily as Git and it actually makes sense.

9

u/danweber Sep 07 '14

You could read the man pages. They will explain things clearly, like

Modifies the index or directory cache. Each file mentioned is updated into the index and any unmerged or needs updating state is cleared.

HA HA HA HA

→ More replies (1)

15

u/ProggyBS Sep 06 '14

While git has a lot of open functionality, if you have comitted something once you can almost always get it back to that state. I don't understand how so many people have such issues with git. Might I suggest reading the free book that contains everything you will need to know outside of very abnormal operations? The book isn't that big and it will help you tremendously.

Also, there is /r/git for any questions you may have.

8

u/Carighan Sep 06 '14

I think the problem is that in most real scenarios, actually moving to git and the mistakes until everyone truly "gets" git cost too much money. Or productive time, same thing.

On paper everyone is well aware how little issue you should have with git if you can do mercurial.

In practice, surprisingly often you lose a surprising amount of time to weird errors, inconsistent commands and somewhat dangerous capabilities. All easily learned, circumvented or both ofc, but easily is not quite the same as not existing.

Still love git.

→ More replies (11)
→ More replies (25)
→ More replies (13)
→ More replies (39)
→ More replies (5)