Working directory
This is the local project folder; you can create it in the Git terminal by using the following:
-
mkdir folderNamecommand, for example,mkdir luxDev
switching to that folder, we use
cd folderNamecommand.To create a file in the folder, we use
type nul > fileName
Then in the event of making changes, we use Git to track the changes.
-
git statuscommand. This command will help us find the untracked changes in files.
Staging
Staging lets you choose what exactly goes into your next commit.
-
git add .is used to stage all changes while, -
git add fileNameif you want to save a single file or 2 to 3 files
Commit
This is where git records your staged changes to be permanent point in project history.
git commit -m "add folder setup and structured the first comment"
A commit doesn't affect your working directory or your staging area; rather, it takes a snapshot of what's currently staged and locks it into history
Git also gives you tools to actually see what's happening at each stage, which helped me trust the process instead of just following steps blindly.
git log shows the history of commits
This prints each commit's unique ID, author, date, and message
git diff shows exactly what changed in a file, line by line, before you commit it. This is what finally made the working directory.
git diff— shows changes in your working directory that are not yet staged
git diff --staged — shows changes that are staged, waiting to be committed
Push
Everything above happens locally, on your own machine. Push is the step where your commit history gets sent to a remote repository (like GitHub), so it's backed up and shareable.
git push origin main
This is the step that made Git "real" for me because before pushing, all my work exists only on my laptop. After pushing, it's on GitHub, visible to anyone I share the repo with, and safe even if my laptop dies tomorrow.
Each stage answer a different question
Working directory: What am I currently changing?
Staging: What do I want to include in my next save point?
Commit: What's now permanently recorded in history?
Push: What's now shared with others?
Top comments (0)