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 "developer.karthiksanthosh@gmail.com"
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.
Top comments (1)
nice blog Karthik!