git init
Getting a Git repository is the basic step of using Git to start committing changes to projects and tracking them.
What’s a Git Repo?
A repository is a folder created inside the project that can help you record and keep track of all commits. This folder is created once the command “git init” is run in the command prompt. This folder is called a .git folder.
This .git folder contains many files to aid its functioning. config file, description file, hooks folder, info directory folder, objects folder, refs folder. To learn more about these files see the Git Internals page.
How is a Git Repository Created?
Getting a repository could be achieved by turning an existing local directory into a repository or by cloning an existing one. Whichever you choose will be alright.
To begin with the first method, you have to change directories or folders into the project’s folder. using the “cd” command followed by the project directory path typed into the command line. Afterward, you have to type the command “git init”. which creates the .git folder with all of the necessary files (the repository).
If you’re targeting the second method, then use the command “git clone <url>”. This method clones an already existing directory online that you like or maybe want to contribute to.
The important thing here is that this is a primary step to start tracking your project, but no tracking has occurred so far! There are two commands to follow to achieve that. The “git add <file_name>” and “git commit” commands in this order will help you achieve that. More on this topic in an upcoming post!
This is all for this very primary step in making commits to track your files. Below are some great learning resources that can help you get started and eventually gain solidified basics in Git.
Learning resources:
A free audacity course packed with quizzes:
https://classroom.udacity.com/courses/ud123
https://docs.github.com/en/get-started/quickstart/hello-world