- You have directories and files on your computer which make up your file system
- GIT is a version control system that allows you to manage changes to any part of that file system over time
- A working tree is any directory on your computer that has a GIT repository
- A repository is a collection of commits
- A commit is a type of GIT object that represents a snapshot of a working tree
- A snapshot of a working tree is represented by a GIT tree object
- A tree object is a tree of blobs
- The three fundamental types of GIT objects are commit, tree, and blob
- blobs hold file contents and thus the structure of blob trees reflect the structure of the working tree
- blobs track file size and content. Two files with the same content will be represented by the same blob ID by GIT even if they're on two different machines. Why? Because they have the same content
- Fundamentally, using GIT means manipulating the shape of blob trees
But what about stuff like HEAD, branches, tags, rebase, merge ... etc. Ok, ok. One more minute.
- A HEAD points to the currently checked out commit
- If you checked out a branch, it's tracking that branch
- If you checkout out a commit, it's not tracking new commits. Called a "detached head" because it's not tracking a branch so it's not moving with the branch
- branches and tags are just named commits
- a branch (branch of development) represents the first commit in a tree of commits and tracks new commits made on top of that tree
- a tag represents a specific commit and does not move
- merge and rebase are different ways of bringing together different snapshots of your working tree together
- merge tells git to "just bring shit from main branch A into feature branch B, then create a single new merge commit that represents the new working tree that resulted in the changes you made"
- rebase tells git to "bring each commit from main branch A, let me decide if I want to keep them, and then bring the ones I want to keep into branch B one by one as if I made the changes on branch B"
No comments:
Post a Comment