How to Create a Repo — The Conventional Way
How to Create a Repo — The Conventional Way 관련
Let’s make sure that we understand how the terms we’ve introduced relate to the process of creating a repository. This is just a quick high-level view, before we dive much deeper into this process.
Note — most posts with shell commands show UNIX commands. I will provide commands for both Windows and UNIX, with screenshots from Windows, for the sake of variance. When the commands are exactly the same, I will provide them only once.
We will initialize a new repository using git init repo_1
, and then change our directory to that of the repository using cd repo_1
. By using tree /f .git
we can see that running git init
resulted in quite a few sub-directories inside .git
. (The flag /f
includes files in tree
’s output).
Let's create a file inside the repo_1
directory:
On a Linux system:
This file is within our working directory. Yet, since we haven’t added it to the staging area, it is currently untracked. Let's verify using git status
:
The new file is untracked as we haven’t added it to the staging area, and it wasn’t included in a previous commit
We can now add this file to the staging area by using git add new_file.txt
. We can verify that it has been staged by running git status
:
Adding the new file to the staging area
We can now create a commit using git commit
:
Has something changed within .git
directory? Let’s run tree /f .git
to check:
A lot of things have changed within .git
Apparently, quite a lot has changed. It's time to dive deeper into the structure of .git
and understand what is going on under the hood when we run git init
, git add
or git commit
.