Categories
Git

What exactly are Git Commands?

Git cammands do one of three things:

  • Add files and directories to the staging area.

  • Build commits (a new node in the graph).

  • Move labels from one node to another.

    • E.g., git checkout feature.
    • When you type “git commit”, you’re just moving the label for that branch to the node Git created when you staged content (HEAD now point to INDEX).

Git refers to a label as a reference. References make commits reachable (like address pointers). Local branch references move when you perform commands like “git commit”, “git merge”, “git rebase”, “git reset”. Remote branch references move when you perform commands like “git push”. Think of a branch as a time-line (alternate universes).

Categories
Git

Experimentation Strategy

Before you attempt a Git operation…

  1. Create a new branch (like you would a saved game).
  2. Start gitK – so you can see the current state of the branch visually.
  3. Make your change (perform the operation).
  4. Before you refresh gitK, try to guess at what the change will look like.
  5. Run gitK and check the result.
Categories
Git What is Git?

The Git Repository

Git manages repositories as a data structure layered on top of the file system. In Git, you think about changesets, also known as commits. A changeset means conceptually different things on different levels (and this trips-up newbs). A change set is a:

  • Concise list of the changes between one revision and the next.
  • Commit.
  • Snapshot.
  • Hash.
  • Reference ID.
  • Pointer.
  • Tree.
  • Node in a graph.

A Git repository is an object-oriented database. The schema of its data structure is that of an Acyclic Directed Graph. The Objects in the database are the nodes in the graph (trees, folders, tags). Each node is a change-set. It’s a snap-shot of the current state of a branch, and it is called a “Commit,” and the edges are pointers to the previous node.

Commits are objects that contain pointers to the previous commit (parent – child relationship). Merges are commits that point to two or more parent commits.

Categories
Git What is Git?

What is Git?

Simply – Git is a utility program for managing versions of your source code files

Git is a version control system. If you didn’t already know this, version control systems are programs used in software development projects that provide a convenient way to backup a development team’s work in progress.

Note: In development projects involving multiple developers, Git provides a way for the developers to develop their individual contributions independently, and then when the code is ready, to merge their bits into the code base.

Learning resources

The following table contains links to the learning resources that I used to write this cookbook.

Resource Description
Git for Ages Four and Up To speed up your climb up the learning curve, you’ve got to see this video.
The Pro Git Book A comprehensive Git reference manual.
Think like a Git A good conceptual discussion.
The official Git documentation Straight from the horse’s mouth.
EGit/Git For Eclipse Users If you’ve installed EGit for Eclipse, then I recommend that you take a look at this help topic.

Git is a distributed version control system

Source Depot and Subversion are centralized version control systems. At the heart of these systems is a central database (or repository). All merges occur at the central database. Git doesn’t work like that. Everyone working on a project using Git takes a copy (an enlistment in the parlance of Git) of the entire repository, and there isn’t a central database. But there is a remote repository that serves as the master or funnel point. By default, this is called origin. Everyone working on the same project synchronizes their local enlistment with the origin repository. That way everyone keeps up to date with everyone else’s work.

Git isn’t based on the file system

Unlike all other version control systems, Git isn’t file system-based. The Git system is abstracted on top of the file system. To use Git successfully, you have to understand the nature of Git, and the way that Git works. The road to getting there isn’t easy because it requires comprehending a paradigm shift. To an extent, you must unlearn what you understand about source control systems per se. So, to be successful, you must – free your mind!

Eclipse cheat sheets

In Eclipse, if you click Help > Search, the Help tab appears and it has an input field for searching the local help system. If you type git into it and press Return, a list of candidate topic links appears. The first one is “Cloning a Git Repository”. Click it, and the “Cheat Sheets” tab appears. This is interesting. This seems to be a help system that is tied to a Wizard-driven interface, which makes it into a cool tutorial/walk-through system.