What is the famous git?

Git is a distributed version-control system for tracking changes in source code during software development. It is designed for coordinating work among programmers, but it can be used to track changes in any set of files

Difference between git and github

Having trouble understanding the difference between git and git hub? Worry not we've all been there. Github is the online version of git, you can upload your code to it, store it there, share it with other great programmers who can view your code.

Setting up Git

Step 1

Download git from the official site here!

https://git-scm.com/downloads

Step 2

Install it on your machine.

Step 3

Open command prompt in Windows.

Step 4

Go to a folder you want to track with git.

Step 5

And type command "git init" to initialze it.

Following are the essential commands :

(Execute them in the sequence they are written)


1. To initialize a folder to be a git repo use:

git init

This is the first of all commands, you have to make the folder a git repo first in order to track it.


2. To check status use:

git status

This command shows status for your folder.


3.To add your files

git add .

In order to save our files on git we first need to add them to the staging area.


4. To commit files use:

git commit -m "Message"

This command commits all the changes to the repo, we can add a message by using -m. git add . is pre-requisite of this command.


This was all for saving files to your repo.


Here is how to revert to an older version of your file.


1. To find id of the commit you want to revert to

git log --oneline

This shows log containing data and id of all the commits made to this repo.


2. To revert back to older version:

git checkout id filename

We get id from git log --oneline and use it here, we then specify the filename we want to revert and its done.