1. 📁 Initialize a Git repository

git init

Creates a new local Git repository in your current directory (e.g., 24MCR001).


2. ➕ Add a file to the staging area

git add 24MCR050.txt

Stages 24MCR050.txt to be included in the next commit.


3. ✅ Commit the staged file

git commit -m "Added Personal Details"

Creates a commit with a clear message describing the changes.


4. 📋 Check the Git status

git status

Shows the current status of your working directory and staging area — useful to confirm what’s staged or modified.


5. 🕓 View commit history

git log

Displays a list of commits, starting with the most recent.


6. 🌐 Link your local repo to GitHub

git remote add origin https://github.com/karthikio/24MCR050.git

Connects your local repository to a remote GitHub repository.


7. 🌿 Check the current branch

git branch

By default, Git creates a branch named master.


8. 🔀 Rename branch to main (recommended)

git branch -M main

Renames master to main — the new standard for default branches.


9. 👤 Set your global Git config

git config --global user.email "[email protected]"
git config --global user.name "karthikio"

Sets your identity globally for Git commits.


10. 🚀 Push your code to GitHub

git push -u origin main

Pushes the main branch to the remote repository and sets the upstream so you can use git push and git pull without arguments next time.


🔄 Updating Files Later

Once you've done the initial setup, any time you modify or add files, follow these steps again:

git add .
git commit -m "Your commit message"
git push origin main

This will stage all changes, commit them with a message, and push to the main branch on GitHub.


Image description
Image description
Image description