Committing code to keep it safe
To benefit from all the advantages described previously, you need to know how to add files to Git. How do you do that?
First, let’s discuss the concept of a repository, which is often shortened to repo A repository is a place where Git stores a project’s files and a history of all the changes made to those files. It’s the bank vault where it puts files to keep them safe.
There are two main ways to create a repository. The first way is to convert an ordinary directory on your Linux, macOS, or Windows filesystem into a Git repository. This is easy: use the git init
command from inside the directory, and voilà – it turns into a Git repository. Then, you can use the git status
command to prove that it’s a repo.
Let’s use those commands to create a new repository for our Hats for Cats project. First, make a new directory that will become a repository, and move into that directory (the example in this...