Skip to main content

Command Palette

Search for a command to run...

Create Local GIT Repo

Updated
•3 min read•View as Markdown
Create Local GIT Repo
K
Hi, I’m Khushi Dubey. I work with Cloud and DevOps technologies, with a focus on AWS, Linux, Docker, Kubernetes, Terraform, and CI/CD. Here, I document my hands-on work, technical experiments, and things I learn while working with infrastructure and automation.

What is a Local Git Repository?

A Git repository (or "repo" for short) is like a folder where you can store your project files. Git helps you track changes, save different versions of your work, and even collaborate with others. A local repository means it’s stored on your computer, not online.


What You’ll Need

  1. Git Installed: If you don’t have Git installed, download it from git-scm.com. Just follow the installation steps—it’s like installing any other software.

  1. A Project Folder: This is where your files (like code, images, or documents) will live.

Step 1: Open Your Terminal or Command Prompt

  • On Windows: Press Win + R, type cmd, and hit Enter.

  • On Mac: Open the Terminal app (you can find it in Applications > Utilities).

  • On Linux: Open your terminal (usually Ctrl + Alt + T).

Don’t be scared of the terminal—it’s just a way to talk to your computer using text commands.


Step 2: Navigate to Your Project Folder

Let’s say your project folder is on your desktop. Here’s how to go there:

  1. Type cd (which stands for "change directory") followed by the path to your folder.

    • For example:

      • On Windows: cd C:\Users\YourName\Desktop\MyProject

      • On Mac/Linux: cd /Users/YourName/Desktop/MyProject

  2. Press Enter. Now you’re inside your project folder!


Step 3: Initialize the Git Repository

This is where the magic happens! To turn your folder into a Git repository, type:

git init

Then press Enter.
You’ll see a message like:
Initialized empty Git repository in /path/to/your/folder/.git/

This means Git is now tracking your folder. (You won’t see anything change visually, but trust me, it’s working!)


Step 4: Add Your Files to the Repository

Now, let’s tell Git which files to track. If you have files in your folder, type:

Copy

git add .

The . means "add all files in this folder." If you only want to add specific files, replace . with the file name, like git add myfile.txt.


Step 5: Commit Your Changes

A "commit" is like saving a snapshot of your project. To commit your files, type:

Copy

git commit -m "First commit"

The -m stands for "message," and "First commit" is just a note to remind you what this snapshot is about. You can write anything here, like "Added homepage design" or "Fixed the bug".


Step 6: Check Your Work

To see the status of your repository, type:

Copy

git status

This will show you which files are tracked, untracked, or modified. It’s a great way to make sure everything is working as expected.


Step 7: Keep Working and Saving Changes

As you make changes to your project, you can repeat the process:

  1. Add your changes: git add .

  2. Commit them: git commit -m "Your message here"

Each commit saves a new version of your project, so you can always go back if something goes wrong.


Bonus Tips

  • Check Your History: To see all your commits, type git log. It’ll show you a list of snapshots with messages and dates.

  • Undo Mistakes: If you mess up, Git has tools to help you undo changes. For example, git checkout -- filename will undo changes to a specific file.


Congratulations!

You’ve just created your first local Git repository! 🎉 Now you can track changes to your project, save different versions.


linkedin: https://www.linkedin.com/in/khushi-dubey-6036a2305

Thank You!

N

Great points throughout. Short, clear, and meaningful.

More from this blog

Git & GitHub Diaries

11 posts