Hello everyone ! Welcome back
Today we will talk about two of the most commonly used Git command: git status and git commit . But before we dive into those, let’s quickly go over a few important terms that will make thins clear.
In my first blog,I explained what Git is — as you might remember , Git helps you track your code and any changes made to it. It also allows you to save (or commit) those changes to your local repository whenever you want.
When you are working with Git, there are 3 main areas you’ll be dealing with. Let’s start by understanding what each of them does :
Working Directory
This is the folder where your acutal project files live. You can think of it as your everyday workspace — the place where you creates new folders, add or delete files and make changes to your codes.
- Staging Area
The staging area acts like a bridge between working directory and your local repository. When you make changes in your working directory, you can move them to the staging area using the git add command. Once the changes are in staging area, they are ready to be commited.
- Local Repository
Finally we can have the local repository — this is where Git permanently stores your commit history. It’s created whe you run the git init command , and all your commits are saved inside the hiden .git folder
There’s also something called remote repository , which is basically like GitHub — but don’t worry we will talk more about that later .
So, to summarize:
. The working directory where you you create or edit your project files.
. The staging area is where you prepare your changes before committing them.
. The local repository is where all your commits are stored.
Now that we’ve got that covered, let’s move on to our main topic:
The git status Command
The git status command shows the current state of your repository.
In other words, it’s like asking Git:
“Hey Git, what’s going on with my project right now?”
It answers questions such as:
. Which files have been changed but not yet committed?
. Which files are new and untracked by Git?
. Which files are staged and ready to be committed?
This command is super helpful to keep track of what’s going on in your project before you commit anything.
Before talking about commits, we should mention git add.
This command moves your changes from the working directory to the staging area.
You can add specific files using: git add filename
Or, if you want to add all changes at once: git add .
The git commit Command
Once your files are in the staging area, you can use the git commit command to save them permanently in your local repository.
You can also include a short message describing what you’ve done:git commit -m “Added new project files”
This helps you (and your teammates) understand what each commit was about when you look back at your history.
That’s all for today!
These two commands — and the concepts we discussed before them — are fundamental to understanding how Git works.
Don’t worry if everything doesn’t fully click right now. As we go through more Git lessons, everything will start to make perfect sense.
That’s it from me for today — see you in the next post.
Bye for now! 👋
Top comments (0)