-
Notifications
You must be signed in to change notification settings - Fork 1
Chapter_10
Chris McIntosh edited this page Dec 4, 2019
·
4 revisions
- Files and folders we care about:
HEADindexobjectsrefs
- Git is a content-addressable filesystem
- Key-value store
- Any type of file can be inserted
-
git hash-objectcan add the file to the db -
git cat-filecan display the data
- Tree objects contain a list of sub objects and their names
- Can be used to store commit info as well as directory structure and file name
- Even be used for just a single file
-
git cat-file -p master^{tree}shows the master tree for the HEAD commit
-
git commit-treeadds your tree to the index - Commit objects specify the top level tree for the snapshot, the parent commits, the author and commiter information, a blank line, finally the commit message
- Objects have a header with the size of the content and then the content
- And SHA1 is deterministically generated from the data and the header
- Finally the blob is compressed with zlib
- Git stores references to SHA1's in the refs folder
-
git update-refcan change references - A branch is a simple reference
- Head is a symbolic link to a branch
- If you are in a the "detached head" state then it will actually have data in it
- Simple tags are a dumb ref to a tree
- Annotated tags contain commit like data and a reference to the commit object that is tagged
- Technically you can tag any object
- Public keys for instance can be stored and tagged
- Stored in the refs subdirectory
- refer to the remote you have saved
-
git gcwill force packing files - Git can look at blobs that have similar patterns and store one copy and the deltas
- Tells git how to track the remote
- Format is
(+?)<source location>:<destination location>-
+refs/heads/*:refs/remotes/origin/*as a default example for origin
-
- You can use the refspec to delete stuff on origin if you want, by leaving off the source
- Used by a clone without auth
- Uses the
info/refsfile which is created with thepost-receivehook - Uses basic HTTP
-
send-packandreceive-packare used to work with the smart protocol to upload data- Work over SSH
-
fetch-packandupload-packare used to download data
-
git gc --autoonly does anything when you have a lot of loose files or packs- Configurable but around 7k loose files or 50 packs
-
gcwill pack up loose files into a pack
-
git reflogrecords what HEAD has pointed to - You can use this to find the lost commit hash
-
git branch <name> <hash you want to save>will create a branch pointing to your lost commits -
git fsck --fullwill show you all dangling objects if you for instance lost your reflog- This probably implies that if you do a gc you will lose your data, that you have already gone out of your way to lose
- You can use
filter-branchto rewrite history bygit rm'ing the file you want gone - Will have to inspect packs to find the sha1 of the file you care about and then find the commits that touched the file and then work backward from there
- Not super useful right now, but bookmark the page for when it comes in handy
- The Debugging env vars are going to be great