Ufraan's Notes Digital garden & personal knowledge base
Last modified: Jun 28, 2026Home / 01_core / Git Fundamentals (Introduction).Md

core

Install git - https://git-scm.com/downloads

Terminologies:


Example for tracking an entire folder:

Git checkpoints.png A “commit” is like a checkpoint, as discussed earlier in a game. It captures the state of your project at a specific moment, allowing you to return to it if needed.

  1. Working Directory: First, you need to create a working directory, which means you must initialize it with git init.
  2. Next, use the command git add <file_name> (not just git add), or git add . to add all files in the current directory. This command moves the specified files into the staging area.
  3. Staging Area: This is the place where your changes are ready to be committed but have not been committed yet. Think of it as “ready to make a checkpoint.” It’s where you prepare your changes before officially recording them.
  4. Once you’re ready, use the command git commit to create a commit, which acts as a checkpoint. After you run this, the repository enters the commit stage, and your changes are saved in the local repository.
  5. To upload your repository to a cloud provider like GitHub, use the git push command. This uploads all the files from your local repository to GitHub, making your project available online.

Let’s dive into a practical example to better understand the workflow!

Prerequisites: Visual Studio Code (VSCode) and Git. Make sure you are signed in to Github within VSCode

  1. Create a Folder:

    First, create a new folder on your computer, and then open it in Visual Studio Code.

  2. Initialize Git Repository:

    Inside VSCode, open the terminal and run the command:

    git init

    This will initialize a new Git repository in your folder.

  3. Check Git Status:

    Run the command:

    git status

    This will show the current state of your repository, confirming that the folder is now being tracked by Git.

git_status command.png

  1. Create Two Files:

    Inside the folder, create two new text files:

    • testone.txt
    • testtwo.txt 5. Now, to start tracking changes for the testone.txt file, run the following command:

git add testone.txt

  1. Now, run the following command to check the status:

git status git_status command 2.png The git status output shows you're on the master branch with no commits. testone.txt is staged for commit, while testtwo.txt is untracked as we had not mentioned it in the previous command.

  1. To commit your changes, use the command:

git commit -m "Your commit message"

This creates a snapshot of the staged changes with the message you provide, describing what the commit includes.

For example: git commit -m "Add testone.txt" git_commit command.png Make sure to write meaningful commit messages that clearly describe the changes you've made.

Just a reminder, we are here exactly in the workflow: repo - git workflow.png in the REPO stage

  1. Now, go ahead and run git status again. You should see something like this: git_status command 3.png This means that testtwo.txt is still untracked and hasn't been added to the staging area yet.

  2. Let’s add testtwo.txt to the staging area by running the following command: git add testtwo.txt.

  3. Now, try committing testtwo.txt on your own with a meaningful message!

  4. After committing, you can run git log to view the commit history and see the details of your recent commits. git log &ndash;oneline command.png

Congrats. You’re done with the absolute fundamentals..

Atomic Commits: Focus on one feature, component, or fix per commit. Avoid adding unrelated changes in a single commit. One Commit, One Fix: If you’re fixing bugs, commit each bug fix separately—one commit for one bug. Commit Message Tense: There’s a debate on whether to use present or past tense in commit messages. Official Recommendation: Use present tense in the imperative mood (e.g., “Add a function to connect to the database”). Personal Preference: While the official guideline is clear, how you write your commit messages is ultimately up to you.

Related: Git Internal Working and Configs.