git basics
what is git?
A git is a software used to track or we can say it is used to track the versions of the software
why git is used?
git is used to see the track the changes we do in a code with time to track that
example___________
lets say we are building a project and we want to track the changes we do time to time lets day
today i wrote some code in the file hello.js then tommorrow i wrote in world.js then next then next , what if i want to see what change or what code i have written in the first day or who has contributed to this feature or who has builded this feature i can all that thing using git and one more thing git is a software and github is a online service build on top of github.
git basics and termonologies?
git is an open source software. to intilaize we write the commands git init in the terminal to initilaize the git in our project.
first we do git init , to intilazie
then we do git add <filename> or if we have to add everything we did we can also write like this git add .
then third step we do git commit -m"a small message” and after the commig we get the hash of the change we did that hash is used to compare the change we did.
how git works in layman language
first we make a folder/repo no nothing is intialized to track the change
then we do git init , a folder is created called a .git that are hidden but we can go inside it and see what other sub folder are there.
then we have command git add the take all the code that we have written to the place called a staging area means that code is ready to commit yet it is not.
then we do git commit that means yes we are ready to track all the and every commit has its own number or id called as hash by which we can say yes this change belongs to this commit.
one most important thing that we called as head
what is head ?
head is kind of a pointer we can say every commit we newly do there is a head on it that this is the new change or new thing that we currently have
common commads we use?
git init
git add . / <filename>
git commit -m “message”
git diff to see the difference
ls list items
ls -a to see the git hidden file
git status to check the status
git log to see the list of commits or changes we do
git branch for braching
git revert to revert the changes we do
git reset - - hard <hash>