So, you’ve just started learning web development and are new to Git? You might not be familiar with the power and benefits of Git yet, but let me tell you, the earlier you learn to use it, the better for you.
If you’ve created a local folder with your development work and want to make it a local Git repository. Here’s how to do it.
I’m assuming you’re using VSCode.
With VSCode open in the directory, open the Terminal, and then run these commands:
1. Initialize the Repo
git init
This will initialize the repository.
Here’s what happens under the hood when you use this command:
Git creates a hidden .git directory inside your current folder. This is where it stores all the information related to your repository. It doesn’t do anything else.
2. Add Files to the Repo
git add .
When you use git add . command (the dot means everything in the current directory), Git starts tracking all files in your project directory. It doesn’t move any files, just starts tracking them.
3. Make Your First Commit
git commit -m "Initial commit"
Commit is like taking a snapshot of your project at that moment. It’s saved in that special folder on your computer, but it’s not on GitHub yet.
That is it for now! In next guide, I will show you how to create repo on GitHub and push these files there.