🧑‍💻 Step-by-Step Git Commands for Beginners: From Init to Push
If you're just getting started with Git and GitHub, this guide walks you through the essential commands you need to create your first repository, commit your files, and push your code to GitHub. Let’s break it down step by step with clear explanations.

1️⃣ Initialize a Git Repository
First, navigate to your project folder (here it's named 24MCR053) and initialize a Git repository:

git init
This command sets up Git in your current folder so it can start tracking your files.

2️⃣ Add a File to the Staging Area
Suppose you’ve created a file named 24MCR053.txt. To stage this file (prepare it for commit):

git add 24MCR053.txt
This tells Git to keep track of this file and include it in your next commit.

3️⃣ Commit the File
Now that the file is staged, let’s commit it with a message:

git commit -m "Added Personal Details"
This saves the current version of your file in Git history with a helpful message.

4️⃣ Check Git Status
Want to see the status of your files? Use:

git status
This command shows which files are staged, unstaged, or untracked.

5️⃣ View Commit History
To see your commit history so far:

git log
This will display the list of commits you’ve made, along with their messages and IDs.

6️⃣ Add Remote GitHub Repository
Now let’s connect your local Git repo to a GitHub repository:

git remote add origin https://github.com/KavinT06/24MCR053.git
This command links your local repo to the remote one on GitHub.

7️⃣ Check the Current Branch
To find out what branch you are currently on:

git branch
By default, Git names it master (though this may change depending on your Git version).

8️⃣ Rename Branch to main
If you want to rename your branch from master to main:

git branch -M main
GitHub prefers using main as the default branch name.

9️⃣ Set Global Git Config (User Info)
Before pushing to GitHub, set your identity:

git config --global user.email "itskavin47@gmail.com"
git config --global user.name "KavinT06"
This sets your name and email globally for Git commits.

🔟 Push Code to Remote for the First Time
Finally, push your code to GitHub and set the upstream branch:

git push -u origin main
This uploads your code to GitHub and links the local main branch with the remote one.

Image description

Image description

Image description

🔁 After Modifying or Adding New Files
If you later modify files or add new ones, follow these steps again:

git add .
git commit -m "Your commit message here"
git push origin main
This sequence stages all changes, commits them with a message, and pushes them to GitHub.

✅ Conclusion
With these simple Git commands, you're well on your way to mastering version control. Whether you're building a personal project or collaborating on a team, these steps form the foundation of your Git workflow. Happy coding! 🚀