Skip to main content

Command Palette

Search for a command to run...

Git & GitHub

Published
2 min read

Hello everyone!

Today we going to learn how we can upload our code to github using git. First, What is Git??? Git is mainly a version control system used to keep a track of changes occurring in our projects. We use git make regular entries about the changes happening in our codebase.

Let's start!

Install git if you didn't.

Then open your code folder and then open gitbash here by just right clicking inside the folder.

Note: You need to configure git to get 'open gitbash here' option while installing git

Here comes the commands

Your first command is

git init

this will initialize the empty git repository as shown in the picture

01.PNG

Now next command is to add a README.md

git add README.md

It's a set of useful information about a project and a kind of manual. It is the first file Github or any Git hosting site will show when someone opens your repository.

Now next is the commit command or commit messages. Whatever changes you are pushing to github you can mention them in quotes.

git commit -m "first commit"

Let's add a main branch

git branch -M main

The default branch name in Git is master . As we start making commits, we're given a main branch that points to the last commit we made.

Now it's time to add the github repository where we are going to push our code.

git remote add origin https://github.com/piyush0001-wq/code.git

You will get your repository url from github when you make new repository.

Done with all, Finally let's push all this code to the github

git push -u origin main

This will push your code with the commit message you mentioned.

Open and check you repository you will get your code there.

Thank You.

P

Really helpful for beginners.

1