Wednesday, May 01, 2013

Git 101 - Beginners guide to groking [command line] Git

DZone - Git Explained: For Beginners

I’m working with Git now for about two years but only for my personal projects and those I have on GitHub. At work we still use TFS and SVN (as of now). Recently Paolo Perrotta came to our company to hold a course about Agile planning and since Git was quite new to most of my mates, he also quickly explained Git in the context of refactoring. I really liked his approach of explaining it and that’s why I’d like to replicate his explanation here.

Just before we start..

How is Git different from other VCS (Version Control Systems)? Probably the most obvious difference is that Git is distributed (unlike SVN or TFS for instance). This means, you’ll have a local repository which lives inside a special folder named .git and you’ll normally (but not necessarily) have a remote, central repository where different collaborators may contribute their code. Note that each of those contributors has an exact clone of the repository on their local workstation.

Git itself can be imagined as something that sits on top of your file system and manipulates files. Even better, you can imagine Git as a tree structure where each commit creates a new node in that tree. Nearly all Git commands actually serve to navigate on this tree and to manipulate it accordingly.  Git is just as legitimate in the enterprise as any other VCS.
As such in this tutorial I’d like to take a look at how Git works by viewing a Git repository from the point of view of the tree it constructs. To do so I walk through some common use cases like

  • adding/modifying a new file
  • creating and merging a branch with and without merge conflicts
  • Viewing the history/changelog
  • Performing a rollback to a certain commit
  • Sharing/synching your code to a remote/central repository

Terminology

...

imageimage

Great introduction to Git for those who want to grok it and it's original command line usage...

No comments: