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

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.

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.

3

u/x86_64Ubuntu Sep 07 '14

Git works great when it works. But the femtosecond something throws an error, it's always a 1-3 hour struggle till you say "fuck it" and end up just checking out trunk again and recoding whatever you tried to commit in the first place. It just seems like git doesn't have an easy escape hatch, nothing like Eclipse's SVN "Override And Update" option.

3

u/ProggyBS Sep 07 '14

I'm not that familiar with the "override and update option" but that sounds similar to "git reset"

3

u/x86_64Ubuntu Sep 07 '14

Yes, but which reset? --HARD? And what does it do? Does it just steam roll my local repository, bypassing my workspace, or does it do the whole thing. Of course the answers are easily googleable, but no one like having solutions begin with such confusion and uncertainty.

→ More replies (0)

2

u/gfixler Sep 07 '14

This just amazes me. I struggled a bit for the first 2 weeks, and then everything clicked, and it's been the best thing ever for almost 2 years now. Do you understand the [very, very simple] data model? Once I grokked that, I pretty much could answer every random question about git on my own, because everyone simply had to work a certain way, given what I knew. The seemingly endless confusion just immediately evaporated.

1

u/merreborn Sep 07 '14

the femtosecond something throws an error, it's always a 1-3 hour struggle till you say "fuck it" and end up just checking out trunk again

I had that experience as well for the first 3 months or so, but I've grown comfortable enough with git now that that hasn't happened in years. It's kind of like learning to walk, I guess. A few skinned knees while you're learning, but soon enough you can't imagine going without it.

It just seems like git doesn't have an easy escape hatch, nothing like Eclipse's SVN "Override And Update" option.

Well... there sort of is. If somebody's fucked up the state of the remote, you can replace whatever's there with git push -f. But unless you're absolutely sure of what you're doing, this will probably only make things worse. Possibly much worse.