Live data from Hacker News

Got 15 minutes and want to learn Git?

try.github.com

71–80 of 178 posts

Re: Got 15 minutes and want to learn Git?

#71

Earlier quoted context omitted.

I figured out Git, and I'm not that clever, so don't worry! The staging area (aka the index) is where you put things before they become a commit. You don't always want to commit all of your changes at once. The index is there so you can commit the changes you want instead of just committing all the changes every time. `git commit` means "turn the contents of the index into a commit". A commit is a set of changes that…

Unfortunately you fell right into the trap he said everyone trying to explain Git does. The first paragraph is complete nonsense unless you already understand it. You first call it a staging area and then you clarify with an "index," but you never clarify what an index is?! The second paragraph doesn't improve the situation much. Ultimately I think there is a language breakdown here. People who explain Git seem to be…

[deleted]

Re: Got 15 minutes and want to learn Git?

#72
post #30

NOTE: This is not a rant, I'm just trying to give you a peek into my mind as I tried out this tutorial. I'm doing my best to describe my confusion. I have no clue how to use Git, and I've been trying to wrap my head around it for a while. Unfortunately, this is yet another tutorial that is very frustrating even though it's designed to target noobs like myself. So, I added octocat.txt to my staging area. Success! ...…

I can empathize, been in a similar situation myself. Most of the git tutorials out there have a problem that they don't explain much of the 'why' and just tell about the 'how'. They are telling mostly about commands and not about the concepts behind it.

Some guy at Harvard wrote a great tutorial[1] on understanding git conceptually. It has been on of the best git tutorials I have read myself.

[1] Understand Git Conceptually - http://www.eecs.harvard.edu/~cduan/technical/git/

Re: Got 15 minutes and want to learn Git?

#73

Earlier quoted context omitted.

I figured out Git, and I'm not that clever, so don't worry! The staging area (aka the index) is where you put things before they become a commit. You don't always want to commit all of your changes at once. The index is there so you can commit the changes you want instead of just committing all the changes every time. `git commit` means "turn the contents of the index into a commit". A commit is a set of changes that…

Unfortunately you fell right into the trap he said everyone trying to explain Git does. The first paragraph is complete nonsense unless you already understand it. You first call it a staging area and then you clarify with an "index," but you never clarify what an index is?! The second paragraph doesn't improve the situation much. Ultimately I think there is a language breakdown here. People who explain Git seem to be…

I suppose you have to know the general idea of a Version Control System (VCS) first before you can understand how Git does version control. I'll try my hand at it.

A Version Control System is a software system that uses files to save different versions of your source code (really, it can save any file, but it works best with source code). The system also lets you revert back to an old version of your code, so you can try something radical out on your code knowing that you have a safe version tucked away in your version control system.

A 'commit' is when you tell the VCS to take a "snapshot" of your files and then save that in its system. Git implements 'commits' with three-location system: the working index (the files on your computer), the staging index (Git's log of what files you want to change), and then the actual commit index (where all the versions are saved). When you stage a file, you tell Git to add the name of that file to it's internal log, telling Git that you want that file to be saved in a version. After you have told Git what files to save (by "staging" them), you can commit (with 'git commit') to save that snapshot of your staged files. Later on, you can revert to the snapshot through git commands.

Hope this helps!

Re: Got 15 minutes and want to learn Git?

#74
post #56

Earlier quoted context omitted.

I sympathize. What is really necessary are not tutorials on how to use Git--it isn't that hard, after all, for most of us--but more of a description of actual workflow. Not HOW you issue Git commands; but how to use Git. It would be interesting to read articles about how a single programmer uses Git, how a small programming team, how a distributed team uses Git. Similar articles about how a team producing art, or tex…

Agreed. And not only for Git. For basically anything else in programming land you get to have either hands on quick guides or spec listing. There's serious shortage of good, moderately abstract, short overviews of what something actually does and how it does it. Take Vim for instance. When I first got to it, I found only resources that are paraphrased with "this command does that. that command does that... nth comman…

> For Node.js, I found some talks/presentations from its creator that really hit this spot.

Mind sharing the specific ones which worked for you?

> I still haven't found anything like that for Git.

I shared a nice conceptual tutorial about git in a reply in another comment of the same thread. Here it is, http://news.ycombinator.com/item?id=4200426

Re: Got 15 minutes and want to learn Git?

#75
post #30

NOTE: This is not a rant, I'm just trying to give you a peek into my mind as I tried out this tutorial. I'm doing my best to describe my confusion. I have no clue how to use Git, and I've been trying to wrap my head around it for a while. Unfortunately, this is yet another tutorial that is very frustrating even though it's designed to target noobs like myself. So, I added octocat.txt to my staging area. Success! ...…

Yeah, it should certainly start with some intro explaining the idea of VC and defining words like commit or repo.

Re: Got 15 minutes and want to learn Git?

#76
post #30

NOTE: This is not a rant, I'm just trying to give you a peek into my mind as I tried out this tutorial. I'm doing my best to describe my confusion. I have no clue how to use Git, and I've been trying to wrap my head around it for a while. Unfortunately, this is yet another tutorial that is very frustrating even though it's designed to target noobs like myself. So, I added octocat.txt to my staging area. Success! ...…

The svn book, (and I believe the hg) spends a number of chapters explaining how version control works. It will also give you some background on how things were, and where they're going. If the git docs don't do a good enough job, I suggest you read/skim the introductory chapters of these two free books.

Re: Got 15 minutes and want to learn Git?

#77
post #56
post #30

NOTE: This is not a rant, I'm just trying to give you a peek into my mind as I tried out this tutorial. I'm doing my best to describe my confusion. I have no clue how to use Git, and I've been trying to wrap my head around it for a while. Unfortunately, this is yet another tutorial that is very frustrating even though it's designed to target noobs like myself. So, I added octocat.txt to my staging area. Success! ...…

I sympathize. What is really necessary are not tutorials on how to use Git--it isn't that hard, after all, for most of us--but more of a description of actual workflow. Not HOW you issue Git commands; but how to use Git. It would be interesting to read articles about how a single programmer uses Git, how a small programming team, how a distributed team uses Git. Similar articles about how a team producing art, or tex…

Sometime back, I wrote about my initial Git workflow: http://veerasundar.com/blog/2011/06/git-tutorial-my-git-work...

Re: Got 15 minutes and want to learn Git?

#78
post #55

As someone new to git, I was dissapointed to see that: git add "*.txt" added all of the .txt files from the current directory AND all of the .txt files contained within a subdirectory. I would have expected the same files to get added as those that would have shown up using: ls *.txt For other new users: I've been told that this is an error in the tutorial. The tutorial forced the use of quotes but apparently they ar…

Nice Find! I added it to my git-themed twitter account here: https://twitter.com/#!/gitHater

Let me explain what's happening.

What you are looking at is actually part-git, part unix-shell-y.

You did ls * .txt

Let's try something way crazy, type echo * .txt

What do you see? All of your txt files right? But that's just echo, not ls.

Ahh. Here's the clinch. When you do " * ", that's called either shell "expansion" or "globbing" depending on your shell. Basically, the shell says "ok, before I run your command, I'm going to look at it and see if I need to do anything on my end"

This is why you can do

   $ n=0
   $ echo $n
The shell hijacks your input, replacing "$n" with "0", then feeds it into echo

In your example, the shell has hijacked the star in "ls * .txt", replaced it with all of your txt files, say (a.txt, b.txt) and then ran ls.

That means that ls ACTUALLY got

   ls a.txt b.txt
And THAT's why it works with echo.

---------

So git add "* .txt" works differently, what gives?

Well, when you put things in double or single quotes you are telling the shell "hey, don't do your usual stuff here". The single quotes are more extreme. If we go back to our n=0 example we can try two more things:

   $ n=0
   $ echo $n
   $ echo "$n"
   $ echo '$n'
As you can see, the ' says "relax shell, I have this".

So when you do

    git add "* .txt" 
you are actually passing the "* .txt" to git.

In most reasonable, sensible programs, the program will look for a file named "asterisk dot t x t" in this case.

But alas, our friends at git have decided to be tricky. The ' * ' syntax for git is similar to gitignore-like syntax (http://www.kernel.org/pub/software/scm/git/docs/v1.7.10/giti...)

"Awesome", you exclaim! Not so fast. It's not the same.

So git add '!1' doesn't work. git add 'one/ * * ' doesn't work, only git add ' * ' seems to work.

Why is it so hard? Good question! I haven't any idea. But we can commiserate together ... you know, over twitter.

Have a good one!

Re: Got 15 minutes and want to learn Git?

#79

Earlier quoted context omitted.

Agreed. And not only for Git. For basically anything else in programming land you get to have either hands on quick guides or spec listing. There's serious shortage of good, moderately abstract, short overviews of what something actually does and how it does it. Take Vim for instance. When I first got to it, I found only resources that are paraphrased with "this command does that. that command does that... nth comman…

> For Node.js, I found some talks/presentations from its creator that really hit this spot. Mind sharing the specific ones which worked for you? > I still haven't found anything like that for Git. I shared a nice conceptual tutorial about git in a reply in another comment of the same thread. Here it is, http://news.ycombinator.com/item?id=4200426

Sure. Sorry for not linking to any in the first place.

Here it is http://youtu.be/M-sc73Y-zQA. He got cocky later on, so I don't like very much his presentations of a later date. In this one, he's pretty nervous on occasions. It's cute. :)

I just glanced at the git tutorial provided - it seems it is up my alley. Will check it out later on.

Re: Got 15 minutes and want to learn Git?

#80
post #56
post #30

NOTE: This is not a rant, I'm just trying to give you a peek into my mind as I tried out this tutorial. I'm doing my best to describe my confusion. I have no clue how to use Git, and I've been trying to wrap my head around it for a while. Unfortunately, this is yet another tutorial that is very frustrating even though it's designed to target noobs like myself. So, I added octocat.txt to my staging area. Success! ...…

I sympathize. What is really necessary are not tutorials on how to use Git--it isn't that hard, after all, for most of us--but more of a description of actual workflow. Not HOW you issue Git commands; but how to use Git. It would be interesting to read articles about how a single programmer uses Git, how a small programming team, how a distributed team uses Git. Similar articles about how a team producing art, or tex…

Correction, what we need is both. Tutorials and a description of the workflow. The articles are all nice touches as-well. Knowing how my team could be more organized helps me want to try it out.

And just in-case I came across as an asshole, I liked your post and thought it was great :)

Post reply on HN