the definitive deep dive into the .git folder
Thanks for joining us for "the definitive deep dive into the .git folder". It's an incredible live-demo where we open every file in the .git folder and show what it does.
Here's the links we saw:
- git-explorer is a visualization tool I wrote to look not only at commits but at tree nodes and blob nodes inside the objects folder.
- A Stack Overflow answer about how to un-zlib-compress an object in the .git/objects folder.
- Use a tool to symlink
.git/hooksfiles into a place that you can commit and share:
.git/configis the local configuration for your repo. It overrides the "global" (user-specific) config in
~/.gitconfigwhich overrides the "system" config in your git install directory. Mine is in
- What's in the
.git/indexfile is a great Stack Overflow post listing the format of index files in Git.
- gin is a Python program for reading the
.git/indexfile. Or you could use
- Eric Potter has a great infographic showing all the files inside the .git folder, breaking them nicely into the standard groups: commits (objects), human-readable labels (refs), automation (hooks), configuration, log files, and temp files.
- Nick Quaranto has an excelent post on git ready with a good summary of all the files in the
.gitfolder, and a great review of this talk.
Here's some interesting configuration I have in my user-specific ("global")
- I've set my default branch name to
[init] defaultBranch = main
- Git will auto-correct typos. If I type
git staas, it'll run
[help] autocorrect = 8
8is tenths-of-a-second. So in my case it'll wait 0.8 seconds before running, giving me a chance to change my mind if I don't like the suggestion.
- I've set my default editor to VS Code:
By default any time Git wants to ask me something, it lands in VI which may be less than ideal for new users. (The magic answer is
[core] editor = \"C:\\Users\\Rob\\AppData\\Local\\Programs\\Microsoft VS Code\\bin\\code\" --wait
:q!.) With this setting, it uses a different editor.
- I really like this alias (shortcut):
I frequently start typing
[alias] git = !git $@
gitthen get distracted, then return and type
git statusor another command. Therefore my command becomes
git git status. With this alias, if there's a
git git, it takes the rest and runs it as a shell command. So
git git statusruns
git status. It just works ... as does
git git git git git status.
- Another alias I really enjoy:
I don't use aliases during talks, but it can be a mouth-full to remember all the arguments to display a pretty git history on the terminal. I've taught my fingers that
[alias] hist = log --oneline --graph --decorate --all
git histwill get it done.
- Want to see all the files in the directory that aren't committed?:
Now I type
[alias] ls-ignored = ls-files --others --directory --no-empty-directory
git ls-ignoredand it'll show me all the files that were excluded by the .gitignore file.
The format of this file is an ini file. So you only need the section header once. If you wanted to include all the aliases listed above, you'd add it like this:
[alias] git = !git $@ hist = log --oneline --graph --decorate --all ls-ignored = ls-files --others --directory --no-empty-directory
Hit me up on Twitter @rob_rich and let's continue chatting!