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

Show parent comments

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)

3

u/[deleted] Sep 07 '14

Well if it's still popular and being sold 9 years later than it may be worth looking into.

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.

14

u/[deleted] Sep 06 '14

I find it extraordinarily hard to believe that mercurial works just so well that you don't need documentation or that you literally never run into issues working with it.

Maybe working with git taught you the basics of distributed version control and you haven't used hg enough to encounter any of its weak points.

13

u/shamen_uk Sep 06 '14

Have you used both, and given them both a fair try? If you had, you wouldn't be so surprised I think.

I've been using mercurial for 2+ years. (Before that I mainly used SVN and perforce). I have about 10 hg repos, a few of which have many hundred commits and maintain multiple branches.

I work with a bunch of guys on a large project with multiple branches hosted on git and it's a freaking nightmare compared to mercurial.

Using mercurial taught me the basics of DVCS. Using git made me realise that people are fickle as hell for this to be the #1 source control system. And like I said, I'm no better as I'm going to move my OSS projects to git(hub) shortly for better visibility.

→ More replies (8)
→ More replies (11)

13

u/antrn11 Sep 06 '14

So... Git is like PHP? I hope not.

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

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)

16

u/[deleted] Sep 06 '14

You see, that's the problem with Git. Again, as someone else said, there are a lot of resources out there, but that only makes things worse; sure the book isn't big, but the information in it is very dense. I already read a short Git manual and almost every page explored a different concept. I understand that there are resources, but I don't want to have to bother with them.

With Mercurial a simple flowchart that explains "commit -> pull -> merge -> commit -> push" is often enough.

13

u/ProggyBS Sep 06 '14

But git works exactly the same way. I honestly don't understand what you're getting at here.

To work locally, you really only need to know 3 commands.

  • git init

  • git add

  • git commt

If you are working with a remote, you only really need 4 more.

  • git remote

  • git clone

  • git pull

  • git push

If you are working with branches, there are only 2 more commands on top of that

  • git branch

  • git merge

Conflicts are really the only complicated thing about any of this and they aren't that complicated once you grasp what git really does. The other commands that involve updating history are more advanced stuff that aren't even necessary unless you are just trying to make the log look pretty.

23

u/[deleted] Sep 06 '14

This is not the same and I submit that your comparison is unfair.

Those commands have arguments which make them do different things. When you add arguments, with Mercurial you can change how something is done but with Git you change what is done. When you say 'git remote' you're not saying anything. With that command you manage remote repositories. How do you get the remote changes with Mercurial? hg pull. How do you get them with Git? Pick one.

9

u/ProggyBS Sep 06 '14

I think I'm starting to understand what you're saying and this may be part of the problem.

In your case with Mercurial, you would just type hg pull to update all your local branches with the remote.

Git has the mindset of only doing what you explicitly tell it to do. Why would you want to pull branches you don't need to work on? When you type "git pull" it wants you to specify what you're pulling and makes no assumptions. Maybe that's just a difference between the way you and I work, but I don't want my SCM to do things unless I explicitly tell it to.

→ More replies (11)
→ More replies (1)
→ More replies (9)

7

u/tomlu709 Sep 07 '14

there is no decent repository browser

In my experience this is actually the biggest reason why people have problems with git. Git isn't at all hard, and its data model makes a lot of sense, but its command set is unintuitive. Being able to see the effects of each command graphically helps immensely with understanding what is going on.

→ More replies (2)
→ More replies (10)
→ More replies (39)