Learn the basics of Git and Git hub.

Learn the basics of Git and Git hub.

What is Git and Git hub???

Git-> In simple terms we can say git is a version control systems that helps you manage and keep track of your source code history.

Git hub-> GitHub is an online software development platform used for storing, tracking, and collaborating on software projects. It basically allows you to manage git repository.

Why is git needed?

When a team works on real-life projects, git helps ensure no code conflicts between the developers. Furthermore, the project requirements change often. So a git manages all the versions. If needed, we can also go back to the original code.

what is version control ?

Just like we use the app there we recieves certain updates after particular time in which new verison new features added and sometimes some bugs remove it so similar to app git also supports this feature. Many developers can add their code in parallel. So the version control system easily manages all the updates that are done previously.

For example

let’s say that you’re working on a web development project, and through the course of your revisions, you suddenly notice all of your text has become misaligned. You can bet that some change you made somewhere along the way is the cause. But not to worry; instead of having to crawl back through every line of code, you can just use your version control system to reload earlier versions, until you pinpoint the offending change and correct it.

Git Repositories

If we want to start using Git, we need to know where to host our repositories.

A repository (or “Repo” for short) is a project that contains multiple files.

Now we’ll learn how to use Git & GitHub

GitHub account creation

To create your account, you need to go to GitHub's and signup first.

After signup Lets install git on our system

All the installation process based on windows in this post.

Go to here and install first.

Download 64 or 32 bit version according to your system.

And install them with default settings.

Now open terminal in project folder on your IDE or in Windows Terminal.

type

git --version

if it shows something like this then you are good to go .

git version 2.35.1.windows.2

Now first create a git repository

If you are using on the first time then you need to add email and username first in your system.

add user name and email on your git by using this command:

git config --global user.name "your name"

git config --global user.email "youremail@example.com"

then go back to the git hub

click on this add button

new repo.avif

give it a name and click Create Repository.

Now come back to terminal and use these commands

first you have to initialize the git into your project folder write

git init

after this check the status of the file by using

git status

after this you have to add the file by using

git add [file name]

lets say file name is index.html

git add index.html

this is for when you have to add a single file

for all the files you want to add use

git add --all

After this :

commit”: Now that we have added the files of our choice, we need to write a message to explain what we have done.

git commit -m "enter the message which you want to write "

Now

Add files to main branch

git branch -M main

Now add your remote repository link

git remote add origin (link)

With this final command push your code form local repository to github.

git push origin master

I hope you got a better understanding about Git and how to get started with it

Did you find this article valuable?

Support jitender blog by becoming a sponsor. Any amount is appreciated!