Live data from Hacker News

Learn Git Branching

pcottle.github.com

31–40 of 144 posts

Re: Learn Git Branching

#32
post #2

It would be great if the help page popped up when I first load the site, so I don't have to guess and type "help" at the prompt to find out the purpose of the site. :)

My bad (author here), this was submitted without my knowledge :P The demo here: http://pcottle.github.com/learnGitBranching/?demo Shows the help page, an example level, and the whole shebang

Ah, that's much better!

Re: Learn Git Branching

#33
post #29

What is the difference between doing: git checkout -b bugFix git commit git checkout master git commit git merge bugFix master And git branch bugFix git commit git checkout master git commit git merge bugFix master

Creating a branch with git branch bugFix does not automatically check it out, so you'd have to follow it up with git checkout bugFix but if you do git checkout -b bugFix it will create the branch and then check it out all in one step.

Yup, makes sense. Thanks.

Re: Learn Git Branching

#34

What is the difference between doing: git checkout -b bugFix git commit git checkout master git commit git merge bugFix master And git branch bugFix git commit git checkout master git commit git merge bugFix master

git checkout -b bugFix creates the branch and puts you on that branch, git branch bugFix creates the branch and leaves you where you are, so in your first example you are committing on the branch and then merging to master, in the second example you are always committing to master.

try it in the website and you’ll see that in the second case bugFix never changes. the merge will say nothing needs to be done because bugFix already contains all changesets in master.

Re: Learn Git Branching

#35
post #2

It would be great if the help page popped up when I first load the site, so I don't have to guess and type "help" at the prompt to find out the purpose of the site. :)

I didn't even realise you could type "help". There definitely needs to be some sort of introduction prompt otherwise people (like me) are just gonna leave feeling like they've learned nothing. Still, nice idea.

Sorry, I got to this thread late (author here). The demo link:

http://pcottle.github.com/learnGitBranching/?demo

Is far better

Re: Learn Git Branching

#36
post #29

What is the difference between doing: git checkout -b bugFix git commit git checkout master git commit git merge bugFix master And git branch bugFix git commit git checkout master git commit git merge bugFix master

Creating a branch with git branch bugFix does not automatically check it out, so you'd have to follow it up with git checkout bugFix but if you do git checkout -b bugFix it will create the branch and then check it out all in one step.

Yep! Exactly. The status of the current branch your on is designated by the asterisk (like in real git), but in retrospect I guess it could be a bit more clear...

Re: Learn Git Branching

#37
post #24

I would try it out but, fullscreened, I get the message "That window size is not supported :-/" How about letting me worry about that and continue anyway? What is the worst that could happen, I have to use a scrollbar?

I support a fairly wide range of zoom levels... from +3 levels zoomed in to almost any level zoomed out. The main reason why I can't do more than 4 is the way canvas pixels interact with screen pixels and some of the text positioning logic.

If you're at a normal zoom level and getting that message, certainly let me know -- the zoom level detection logic is a unfortunately pretty hacky.

Re: Learn Git Branching

#38

Earlier quoted context omitted.

Agreed. I'm like you and I was just committing, branching, and merging but learning nothing while clicking around. I'm glad I know now though because I can totally use a lesson on branching. I think branching in Git is one of the most misunderstood parts of Git. I can't tell you how many times I've almost screwed up a repo because I made some mistake merging branches and not pulling from the correct branch when worki…

The implementation of branching in git is so fantastically simple (its literally a commit hash in a file, `cat .git/refs/heads/master` if you don't believe me) that it boggles the mind that so many developers have so much issue with it.

The implementation may be simple but I think what gets people is building a mental model of all your different remotes and branches. If you're working on a single machine this is simple. Add in another remote and it's still simple but adds complexity. Add in 3 remotes, 3 development machiness, and oh say 3 branches and the mental model is hard to juggle. I develop on 3 different machines and even after about 6 months of this setup which is very close to the example I gave I still mess things up because I don't think to check what branch I'm on when I switch machines and pull from the wrong one and other little mistakes like that.

Branching really is a very simple thing to understand but what I think gets people in the end is building a mental model of one's own setup and creating good habits like always running `git status` when sitting down at a new machine to be sure you're on the branch you think you are, always pushing to your main remote before switching machines, and making sure to push to the correct branch in that remote, and so on.

Re: Learn Git Branching

#39

Seems only Chrome exists as a browser. All others need not apply.

Should work on Firefox, Chrome, and Safari. Anything specific you are noticing in another browser??

I rely pretty heavily on the box model for layout, but if you look at the CSS I included almost every browser extension (even Opera)

Re: Learn Git Branching

#40
Nice stuff. This kind of branching visualisation is highly useful. I'd like to work with that kind of interface. I suppose I should use gitk or something similar?

How did you create the branch visualization? Did you use some sort of library for displaying and animating connected nodes, or is it all coded from scratch?

Post reply on HN