Creating a Repository
First, let's create a new directory under our home directory for our work and then change the current working directory to the newly created one:
Then we tell Git to make a repository for our practice_git project. It is a place where Git can store versions of our files:
It is important to note that git init will create a repository that can include subdirectories and their files—there is no need to create separate repositories nested within the practice_git repository, whether subdirectories are present from the beginning or added later. Also, note that the creation of the practice_git directory and its initialization as a repository are completely separate processes.
If we use ls to show the directory’s contents, it appears that nothing has changed:
But if we add the -a flag to show everything, we can see that Git has created a hidden directory within practice_git called .git:
Git uses this special subdirectory to store all the information about the project, including the tracked files and sub-directories located within the project’s directory. If we ever delete the .git subdirectory, we will lose the project’s history.
Next, we will change the default branch to be called main. This might be the default branch depending on your settings and version of git. See the setup episode for more information on this change.
Let' ask Git to tell us the status of our project:
We do not like the branch name "master". Let's change it to main
Let's again ask Git to tell us the status of our project:
If you are using a different version of git, the exact wording of the output might be slightly different.
Last updated