git Quick Reference -- Draft in Progress

This is a draft.  Do not take internally.  Keep away from children and management.

Also, this could be completely wrong.  I'm going from memory for a few things.

Git Book W00

Let's just control a single directory.  No server.  No fancy.  NO root needed.
  sudo yum install git # if you haven't already got it.
  sudo yum install tree # if you're gonna follow the examples in the book
  cd /whatever/directory/you're/gonna/version
  git init
  echo '*.swp' > .gitignore  # so you won't end up versioning files that are open in vi
  git add *
  git commit -a -m "root commit for this directory."  # officially called "root" for the first commit
Edit some things.
  git status # shows you the state now, versus the last commit.
  git add some/new/directory # if you've added more files.
  git add * # if you've added more files and want just plain everything to be added to versioning.
  git commit -a -m "Adding some files.  Modifying some files."

That was fun.

  sha1 hashes represent each file at a particular moment in time.
    like perforce
    you can instruct a server to double-check sha1 hash against file contents when it reads it.

blob (a file), tree (a set of directories and subdirectories), commit (a tree at a moment), tag (some commit with a name applied.)

philosophical difference:
  they don't log deltas, like everyone else.
    perforce, svn, etc -- you check in a diff
  they store snapshots .. so a diff is something you do to the files, it's not the "content," per se.
    you check in a whole tree at a point in time.  (a commit, I guess)
      oh interesting, this means that a file "move" isn't significant to git.
        although there's a command to try to spot the same hash changing places.
      must be interesting to do merges.  or not.  but not as simple as trying to concatenate diffs.

git log
  shows what's been going on, including full commit numbers
  now you can do a git show ID on that commit number.

author and committer of a commit can be different.

HTere's a great diagram here of commit, tree, blob relationships.
  a commit simply refers to the top level tree's hash.
  that tree's content is a decription of the hashes of its conents.
    blobs for each file in the directory.
    tree objects for all directories it contains.
  and so on
    those sub trees index the blobs for *their* files, and trees for their subtrees.
  I'm not doing a good job of explaining ths.

No comments:

Post a Comment