Hello friends, my name is Nikhil Gupta and welcome to this video series of LearnVern. Our today’s topic is version control. Now before starting version control, I want to ask you one question, has it ever happened to you that you have written 200 to 300 lines of code and then mistakenly you clicked on delete button and the whole code disappeared? okay, so this happens with me a lot and not only this, sometimes I forget semicolon and then when I build it error shows in my whole file and sometimes it happens that I create a class and named it lable LABLE okay, and at other places I have called it LABEL means I have used two spelling LABLE and LABEL, so if I make mistake at one place then it is okay but sometimes what happens is I write different spellings in different files means somewhere LABLE and somewhere LABEL.
Now if I have written like this very often then what will happen? I need to search everywhere and I need to check where I have made mistakes okay, so these were small problems but in our day to day life while coding we face many problems. In some cases our file gets deleted and in some cases we need our old code, like how was it earlier means the code which you wrote earlier was working little bit and it had only small problem means if I wanted five then only FIV was appearing and e was not and if you made any change, or I will give you other example I wanted such program which give me fibonacci series okay and in my fibonacci series I want 5 but still 4 is appearing and my 5 number was not appearing, so I thought of making some changes in the code and made some changes and now my whole fibonacci series has gone now, some other series is showing so in such case what will I do? I will need my older code at least I was getting 4 correct, so in that I just have to change little bit but on changing it instead of fibonacci series I got some other series so in such case we want to revert back ,we want our older code, so if I have saved it anywhere or taken backup then I can retrieve it okay. so normally you must also be doing this if you feel this file is important okay, so you will create a txt file or you can keep your project in zip file and sometimes I keep my program online also and I keep it on my computer also and I save it in external disk also, so that if any problem occurs I can retrieve it back so we normally do all these things.
So this thing which we are doing is what? So this whole process is known as version control okay so in version control what is our main purpose? Whatever history of our code we have means all the changes, modifications, deletion, addition so all these information is known as version control okay, so if I want to do version control then I can do that manually also but if you have noticed whenever you try doing it manually, you need to take backup always okay, so you only assume this small program of creating fibonacci series then I can take as many backups as I want but if I am making 5 to 6 changes in a project everyday and my whole project is of 25 MB or for now assume it is of 250 MB okay, and if I take backup 4 times then it will reach till 1 GB okay .so if it is small project then it does not matter much because you have lots of storage available but if your project is big and taking backup everyday matters a lot if we are doing this manually then okay.
So to avoid such scenarios we have another tool known as version control system ,okay. so nowadays using internet you can use many version control systems, now version control system have a small part known as SCM okay, now we have already divided version controls work so the first task would be as its name defines that it has to control its different version like version 1 version 2 etc., not only this if you have done coding on Monday and named it, so that will also be counted as version so in history it is a specific version of specific date it is version of our code only right, so that will also be known as our code’s history, so I want to track all these things and I want to get some information from this so for that I need to use version control okay.
So let’s see what we have in version control, so in version control we have all the information stored like which version is the current version and which version is the previous one and which one is the starting one okay. Now in this we have one more thing known as source code management SCM okay. so it is a small part of version control, so source code’s work in version control is to track any sort of modification that happens in our code. Now this will not create a backup of this, it will just keep record of how many lines of code you have written like today I have 6 lines and earlier I had 5 lines so this kind of history it will store.
So here notice one thing we are not taking backup of whole thing we are just tracking which thing has been changed here, if my today’s code is almost of 25 MB and in that or we will take 250 MB because it will be easy so in that 250MB file I have changed only one line then it will save that one line only and the history will be in KB, but if you take its backup manually then, you will take backup of whole 250 MB right so in such case the file will be very large ,so in such cases SCM will store only history the important things or the changes which have been done in our code I will remember only that much.
So our source code of our large product changes to often, and not only that much, our small change can make huge effect, for example if my project is working in multi chain, multi chain means I have my project but some other person’s project is based on my project and if I am making any change in my project, so because of that any problem occurs then it will affect my project also and other person’s project also and if we have chain of this whole thing and if problem occurs at one point then its effect will be seen till end and its effect will be seen on large application also okay.
So if you make any change because of which error is coming or if delete any file by mistake so in such case many problems are created ,so to tackle these problems we use source code management, which is part of version control okay .so the tools available in SCM tracks history and second thing they save this history as a revision okay, and its technical word is revision so we can name our every revision means what we did on Monday the changes I made in that I can save it through message which will help me in retrieving it back by just checking the code which we did on Monday or prior to that, so due to these tools your old code will also be saved and your new code will also be saved in history and if you want to go through some older codes then you can check in the revision like how it looks?
After that you can again go back to your current revision and if in future you notice anything that the change which I have made is not good and causing problems, then what you can do is you can go back to revision again and apply the older code and make that as your current version and the other code will also be saved so if in future, if you want to reuse that code you can do it and your current version will be your history version. So all these features are provided to you by SCM okay.
Not only this, another task of SCM is normally in this work is divided in two different parts and not only this normally when we talk about version control, we think about the source code saved in my computer but when we talk about version control in software engineering, so I have whole team and in one team I have 5 people and if I change one file between those 5 people then controlling, its version will become very difficult. so this whole process is handled by SCM only, so in SCM we have divided whole process in two parts and the process which takes place on single pc we call that as local SCM means which will be stored on your computer and change files stored in your computer only and we will call that as local SCM.
Similarly in version control we have another part of SCM known as central SCM, so in centralized SCM what happens is whatever your project is which is divided amongst five people, so that project will be merged and saved at one place means as I gave you example last time, I want to make a website in which I have to create login page, profile page and home page so I divided these three pages between three developers so whenever the task is finished of making three pages then what will they do? They will save it in local version control, which means local SCM. Now what will happen is they will push the pages stored on their local SCM onto the server. Now I have used push word because Git also uses this word only and we can call it as transfer also, so it has different terminology in different apps.
So normally what do we do? we will work on local and then transfer it on centralized, so what is the work of centralized SCM? It does not play any role in version control, its main task is to merge all the codes which it is receiving from 5 or more places, merging it means I will give same example if I have four files means I have big project in which 4 pages needs to be created like home page, login page so I have divided that work in 3 different people right now all the three people finished their work and uploaded it now I will have three files now if you notice these three files my login page is not conflicting with my profile page and nor my profile page with home page, but if two developers work on same page at same time then what will happen? Conflict will be seen as both are changing the same lines so if two developers make changes at same time in the same code of the same project then in such cases conflict will arise so here solving such problems becomes difficult.
Normally speaking if two people are working on the same file from different places, is it possible? Manually it is not possible, why? When two people make changes in the same file and when they want to interchange it means both people want the whole code. Then what will happen? Either he needs to merge your code with his code or you need to merge his code with your code. In short we need to transfer one code from here to there. Now if it was simple change then it would be okay but if in whole file you have done same thing which the other person has done so now it will be difficult to search which line was added later and which one is older one, okay so in such case also our centralized SCM works but it notifies you that it tried its best to resolve the conflict automatically but still if any conflict remains means you both have changed at same places means at one place one person is using double equal to and at same place another person is using not equal to now these changes are at same location but change is different one is using equal to and one is using not equal to if keeps equal to, then other person’s code will be wrong and if he keeps not equal to, then first person’s code will be wrong, now such conflicts which computer cannot solve manually or automatically at that time he will raise the conflict so that user can see it and user can resolve it. so this whole thing is done by centralized SCM source code management.
So, this process takes place in our version control managing your source code on local and centralized means all your will be transferred and then merged and then versioning, it is task of centralized source code management okay. So now the mostly commonly used source code management is, if you search on internet so as you search version control system, then you can see some common tools, so the first tool which you can see is Git, this tool is very famous, mostly open source companies use this tool, and it is very easy to use and we have lots of features in this next is apache subversion, this one is older than Git okay, so places where old codes are used or our project is very old so there you can see this subversion okay.
Apart from that we have one more that is mercurial, now what is this mercurial? It is also a version control system only and it is open source and it is used in that way only but it is not that popular it is mostly used for projects of JAVA, and you cannot find it easily okay. then we have one more i.e. revision control system okay. Now the revision control system, the name itself tells us that is very early implementation means it is very old, we can say it was the first and Git is the latest one and one more we have i.e. Azure Devops server now this version control belongs to azure cloud service so you might have noticed when you store something on Google drive, then your documents have their own version and all that is controlled by Google along with its personal version control okay ,but there is no point in reading it in detail we cannot add that in coding.
So main topics for us which we are going to learn in this, which we need to remember and which we can use so the most well known are Git, second is Azure subversion and third is mercurial okay .so this Git is mainly used for local subversion, i.e. local SCM means as we discussed earlier right like we have two options one is centralized and one is local, normally you can install Git locally on your computer and you can connect it along with server okay, so most famous servers of Git are open source where you can store any code and first is Github and it was open source first but now Microsoft owns it and they have also kept it open source only but it is not fixed as we all know Microsoft company, it can privatize it in future, so now Microsoft company owns this github and there you can store git’s repositories and you can store any software on github.
Another implementation is gitlab, okay in gitlab you have two options. now there is difference between github and gitlab, if you store anything on github then it will be on github’s main server but what does gitlab do is it gives you two options, you can keep on your own server also known as public server or you can create your own private server means you can take your own pc use gitlab in it means install it and then in that you can host your own repository then you have to connect to internet and then link it online, and then you can access that server from anywhere so this feature is available in gitlab you can create your private server.
Both of them are almost the same. You have to create a centralized repository which means five people sitting in different locations can transfer their file here and receive from here and it will be revision control management which means watching history, which person has changed where? All that you can check here so this was all about version control.
If you have any comments or questions regarding this course then click on the discussion button given below this video and post it there, and you will be able to discuss the course with learners.
Jay prashant kakade
Its a great platform to learn if u a student instead of putting your time n money out in classes n all get the knowledge as much as you can