The other day I was thinking random things and of course git came to mind as well. One of the things that really distracted me was how git really functions. In some previous posts I had looked a little closer on what WordPress functions, hooks, and filters sort of do. I haven’t really done much posting on that but that is also because I’ve been looking at other things since.
A little more and more on how git does things. I had also looked into how MySQL works internally but that was a temporary thing. Anyways, I started to dive back a little more into how git works and figured I would post here because this may end up helping at least one person who reads this. Other than me.
git init command is one of the first commands I never really looked into. The reason being is that when I first started my git journey it wasn’t the first command I learned. The first command was
git clone. Biggest reason was because it was in just about all the tutorials I had read on how to clone things down using git. Let’s be honest here, it’s not really one of the commands you really think of right away when it comes to using git.
So I began to look a little closer and read the documentation.
git-init – Create an empty Git repository or reinitialize an existing onehttps://git-scm.com/docs/git-init
It threw me off a little bit because I wasn’t quite expecting to see reinitialize. It was pretty cool to read that, and even cooler to know that it can do that. Earlier today I felt like running the command to see what it is that gets created. At the time of writing this git is on version 2.38.1 and I’m using Fedora 37; I ran the command and a few files and directories were created. The following is the structure and files that get created after running the
init command. All of which resides inside of a
.git folder that also gets created in the directory.
├── branches ├── config ├── description ├── HEAD ├── hooks │ ├── applypatch-msg.sample │ ├── commit-msg.sample │ ├── fsmonitor-watchman.sample │ ├── post-update.sample │ ├── pre-applypatch.sample │ ├── pre-commit.sample │ ├── pre-merge-commit.sample │ ├── prepare-commit-msg.sample │ ├── pre-push.sample │ ├── pre-rebase.sample │ ├── pre-receive.sample │ ├── push-to-checkout.sample │ └── update.sample ├── info │ └── exclude ├── objects │ ├── info │ └── pack └── refs ├── heads └── tags
The part I really like is those sample files. It honestly was not something I had expected but again this was the first time I really began to look a little closer on how things are managed and created within git. Each one of those files and folders of course does hold some purpose and the documentation does go cover that.
This is part one I guess. To be honest I’m not really sure how many I want to do but I do know I want to look at other git commands. Hopefully this does turn into a better series than my fun with hooks/functions one I had previously done.