Git Initialising (Basic Commands)

Git Initialising (Basic Commands)

Getting Started with Git! Need 5 minutes only

Git is a powerful tool for managing your code. If you’re just starting out, don’t worry—it’s simpler than it seems! Here's a quick guide to get your project up and running with Git:


Step 1: Start Your Git Journey

To create a Git repository (a place to store and manage your project), open your terminal, navigate to your project folder, and type:

bashCopy codegit init

This creates a hidden .git folder in your project. It’s like turning your folder into a time machine for code.


Step 2: See What’s Happening

Curious about your current Git status? Check which files are being tracked (or not) with:

bashCopy codegit status

Git will tell you what’s ready for the next step and what needs attention.


Step 3: Add Your Files

Let Git know which files you want to track:

  • To track a specific file:

      bashCopy codegit add <file-name>
    
  • To track everything in your project:

      bashCopy codegit add .
    

Step 4: Save Your Work

Once your files are staged (ready for tracking), it’s time to commit them. This creates a snapshot of your project.

bashCopy codegit commit -m "Your message here"

Example:

bashCopy codegit commit -m "Initial commit"

Think of this as writing a note about what changes you made.


Step 5: Connect to the Cloud

Want to back up your code online? First, create a repository on GitHub (or another platform). Then, link your local repo(repository) to it:

bashCopy codegit remote add origin <repository-URL>

Step 6: Share Your Code

Push your code to the online repository with:

bashCopy codegit push -u origin main

(If your branch is named something else, replace main with that branch name.)


Step 7: Set Your Identity

Git needs to know who you are to track your changes properly. Set your name and email like this:

bashCopy codegit config --global user.name "Your Name"
git config --global user.email "you@example.com"

Bonus Tip: Double-Check Your Setup

Want to confirm everything is set up? Run:

bashCopy codegit config --list

It will show your current configurations.


That’s it! You’re all set to use Git for your projects. 🎉
If you ever get stuck, just remember: Git is like a friendly librarian for your code—always ready to help you track, save, and share your work.