Note : This blog does not tell you in details about the commands you need to use.It just explains what they do.
What it basically does is saves different versions of your file.
Like when you write a program,you change the file number of times.
Git helps us to save(in better words 'track') those changes.Thats it.
Imagine you and your team is working on same file on a college project which is index.html
So..You guys are all set to 'type' the already coded file that you have with you.
You both log in with a common id but on different machines and start editing the same file simultaneosly.
You would be like "Hey!From Where did this rascal piece of code is coming from..I never wrote it!!Let me delete this"
And your friend be like "Why this shitty piece of code is getting deleted always..Coding is such a frustrating?Why did they even invent this???"
And the Uparwala be watching and thinking "In naadan balkon ko git nai pata!!"
What do you think will happen?
Yes!file is changed from both ends and gets corrupt.
And this is only you and your friend!Imagine tech giants like flipkart where hundreds of developers are working together!How would they manage all these changes to the same file?
And thats where Git comes into picture!
Now lets see some terms and terminologies.
What is a repository?
Just a fancy name for folder.
There are some commands you need to know if you are using the CLI version.
There is something known as add.
This is how the command is
git add <file_name>
What this command does is adds all your changes to an intermediate agent.
Yes they arent yet given in right hands.
By running this command you only give that file which you have just changed to that middle man.
That middle man in fancy terms is known as stagging area.
Now how to move it safely into right hands and save changes.
For that lets meet this guy.
There is something known as commit
Remember I told you that git saves different versions of your file.
How?Well commit is the answer for that.
For now , see commit as save changes.
Replace commit word with save changes.
You can also imagine it like a game checkpoint.
You are on a mission in GTA and you know there are checkpoints..So if you are killed somehow,you would not need to start all the way from beginning.Your latest checkpoint is where you start from.
The command runs like this:
git commit -m "Initial commit"
-m stands for message.
You change the file every now and then.
You run and you see Oh! ';' is missing,
Again you run Oh!I missed a brace!!
Sometimes you add ,sometimes you delete.
So only saving changes is useless until you get to know what changes have you made!
And hence you have a message associated with every commit.
Isnt that simple?
Every commit has an unique id associated with it.
Push and Pull.
First lets answer this.
Where to push? To your Github Account
From where to pull? From your Github Account.
What to pull?Repositories
What to push?Folder containing the files you are working on(index.html)
Now man?What is this Github now?
Imagine Github is Google Photos.
Right now,the image/file is in your phone(any local machine).
You PUSH(Upload) it to GITHUB(google photos).
And the command is:
But you need to go through the initial setup before running the command.
And there are some files that you want to PULL(download) that you had earlier uploaded to your account and are not there in your local machine right now.
So you PULL(download) the desired repo from your github account by
I think that its enough for this post.
If you have read this till here..Do give it a like and tell me in comments if you really understood or not!
Feel free to correct me if I have went wrong somewhere!
Thank you for reading!