Git For Beginners 2023

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome back aliens my name is Evan Reddy and in this course we are going to learn about Kit now when you build an application apart from learning the language and the tools to build the application there are other things which you have to learn about and one of it is get so that means irrespective of what kind of application you're building it can be mobile web Enterprise you will be using this tool for two reasons one for the Version Control and second for the collaboration and then this tool is actually easy it's just that the concept might be new and most of the thing which we do is through commands and of course you can do most of these things with the help of GUI because most of the ide's provide you with this tool but then when you work with the command line you have more power to change stuff so in this course we are going to learn different things first of all we will understand what is gate how do we do the setup how do you create your own repository how do you create account on GitHub how to install the project commit the project and how do you push your code on the GitHub repository tree how do you create branches and we'll be doing that practically so you will enjoy this course and don't worry the course is designed for the beginners even if you have no idea what git is we will take care of so I hope you will enjoy this course and also make sure don't just watch the video practice The Thing by yourself so whatever I'm doing parallel you can do it on your machine and let me know how it feels or if you have any issues in the comment section git is a distributed version control system now the problem is if you want to understand get you have to first understand what do you mean by Version Control right and then we can discuss about Version Control System then we can discuss about why it is called distributed and then git will make much more sense so let's talk about Version Control see the thing is when you make a project of course it can be any project it can be a software project or it can be uh writing a book or making videos it's all about a project right and when you make a project the way you work is you create different versions of it right okay so if you don't want to say version let's say you make multiple updates so when I start writing a book I will write something and then I will edit the same file or maybe I want to go back to my previous file so let's say if I'm writing chapter 1 I will complete that chapter one and then I will go for chapter two chapter three now at every chapter and I will just try to save it right and then on chapter two I will try to save a file on chapter three I want to save a file or maybe while writing this chapter in between I will do the save right so and saving is very important right otherwise if your laptop crashes you will lose all the data so as a writer we normally say Ctrl s not once multiple times just to be on the safe side the important part here is we want to make the copies of it now there are multiple ways of doing that what you can do is you can save the same file the thing is if you say the same file you will lose the previous file right or what you can do is you can create a new file so every new update will be a new file and as a software developer we used to do that in my college days I remember when we used to create project every time we add a new feature we used to create a new folder and let me know if you have done this or maybe you can just give a smile if you have done this we create a project and then we give a name to it let's say the project is for a quiz application so you will say quiz app and then if you think this is now we have added few features we can say quiz app one quiz app two quiz app3 of course it will have a new updates new features in that particular new folder right and then the moment you feel that project is complete you say quiz app final then you say quiz app final final because maybe you want to make some final changes and then you realize oh there's a bug then you say quiz app final final Final very final okay so this is the type of folder we used to create the thing is why do we do this it's because what if you want to go back to the previous version what if you have created a project and then it's working and now you added new features and then you you thought it is working but it's not there are some bugs you may want to go back to the previous version right now having that version called or having that power or going back to any version that is called Version Control and to achieve this we need to use some software so write some system and that system is called aversion control system so example if you are building a project you will be saving that file multiple times and then you will not replace the older project the older project will be there right so let's say you have a software with X number of features so you got the first two feature in the first version then you got the third feature on the second version and at any given point you can go back to the previous version also what if you are not alone in the project you have multiple people working in the same project how do you collaborate that's also important right so you will get those features with the help of Version Control and as I mentioned before you need a system so which we call it as a version control system so when you talk about Version Control System we can categorize into three parts here the first one is a local version controls which simply means that as a developer or as a Creator if I write software so if I write a book if I write something and if I want to save in my own machine with different versions of course that is local copy right and in my own particular machine I am creating different versions of it maybe having a folder inside a folder then having different folders of it or maybe I can just create a database where I will save all these files again that's my choice or that depends upon the Version Control System but the thing is everything is happening on my machine the problem here is what if I want to collaborate with other people I have let's say five people in the team and they we all want to work on the same project how will we do that and also what if I'm relying on my machine and then one day my machine says okay I'm done I'm not going to start again how will you get your projects and that's where you can't simply rely on local copy and that's when we have one more option which is called cvcs so VCS is version control system cvcs is your centralized version control system now in this case what you do is let's say you have five people in the network or five people want to work on the same project so what you will do is you will use a central repository not the local one but the remote one so all these machines which you are working on in different locations in the world you will be having a centralized version control system now at this point every time you want to make a change you have to get the copy from the centralized system make the changes in your machine and then you have to save it on the centralized version control system which is cbcs now the problem with this is okay first of all let's talk about the advantage the advantage is if you're working in a file of a group everyone have access to it so so they will know what you're working on so let's say you have done something and then when you say save now basically since we're talking about get let's use the word which we're using git call commit so let's say when you commit something to the centralized server now at this point the other people will have a recent code they know what you're doing right but also there's a problem the problem is everything is stored on a central system right what if the central server says I'm done I'm not going to start again your data is gone now right so that's the problem with this centralized version control system now that's where we have to look for an alternative where you should be able to have a copy on your machine as well and not just the current version you should have the history as well because in the centralized version even if your server goes down at least you have a local copy of the current version yes you have it but we don't want just current version what we want is the history right and that's where you can use something called a distributed Version Control System where you will have a local copy but not just the current version you will have the the entire permit history so let's say you have created version one version two version three everything will be present in your local machine as well and you can you can collaborate with the other developers or in your with your colleagues basically so we have done with the first step of what is get by understanding something called version control system now the more theoretical concept you know it will be easier for you to work on the on the git software right so basically git is are distributed which means you will have a local copy of course you can have a remote copy as well there are a lot of options available example let's say if you talk about GitHub gitlab bitbucket all this are your remote repositories so you will have a copy there plus you will have a copy on your local Mission as well so let's say someday if you want to work in a long flight and you don't have internet access you can still work on your project because you have everything in your own machine so let's understand the history of git now it is interesting that's why we have this special video for it the thing is if we talk about any open source project so what happens in open source project is we have multiple people working on the same project but you will say hey that also happens with the normal projects right the thing is in normal projects we have limited set of people let's say if you are working for a company and you are building a project you have let's say a set of people in a team they will be working on it and then you trust everyone because they are a part of a project in the open source project anyone can contribute let's say one day I decided to be a part of one open source project of course it will take some time for me to understand the project and then if I feel hey you know everything is good in this buildup project so let's say it's any OS let's say we have this own telescope OS and then one day I want to contribute to that particular OS I want to add a new feature of let's say a Bluetooth connectivity just for an example I can write my own module and add that in the OS in my machine but if I want the entire world to use it I have to send them the new code right but then how this thing will work how multiple people in the world can contribute to one project in the earlier days we used to do something called archive files or sending the patches right now this is the same thing happen with Linux as well now if you know Linux kernel very famous One the founder is line of starboard and he is very particular about how Linux should work what are the features we should have now initial days when 1991 to 2002 it was more about uh if you want to provide the features you can send patches or you can use archive files but then in 2002 they started using some some proprietary tool called bitkeeper now bitkeeper I think was free at that point and then they started using bitkeepers so that they can get the contribution from the world easily now they don't they don't have to go through a manual process of doing that so they can simply use bitkeeper and they can send their code and then they can do the merging as well now the problem is at one point the policy of beekeeper changed and they started charging now the Linux Community was doing it for free and then the entire world was using Linux for free so they thought it's a good time now to move away from bitkeeper and that's where git was formed of course they tried to make it very different from bitkeeper so bitkeeper was working a different way and git worked in a different way again what is that different way that will understand once we start the actual implementation but that's how in 2005 get started it's not like someone thought hey let's do this version control system no they were using something else just that because of some issue between the bitkeeper and the community they moved away from it and they started using git as I mentioned before git is different from all different version Control Systems right even different from bitkeeper and since it is different it has given some amazing features it is very simple to use it is fast it also allows you something called branching again once we move towards the advanced part of Kit we'll understand what branching means and it's a fun concept to learn and also to implement and it is fully distributed which makes git very famous and I know we have done enough build up and the question is how do we use git we want to collaborate and we want to work with gate so that you can collaborate with different people and we can build a project it doesn't matter is it a proprietary project you're working in a company or open source how do we use it and that will understand in the upcoming videos now it's time to install git of course right we want to work with those commands and as I mentioned before if you want to master gate or if you want to use the features of gate command line or basically commands are the way to go now how do you know that in your machine you have Kit now if you are using Mac basically in Mac if you have installed xcode you will get git by default but if you are using Windows you will not get that so how do we verify so it's very easy you just have to use the command prompt so I will open my command prompt here and or Powershell so you can what you can do is you can search for get version so basically this is the command which you have to fire and when you say enter you can say it says the term git is not recognized as a command okay so if you want to get git on your machine if you are using this on command prompt you will get a different message example if you do that on command prompt and if you say Git Version this is the message you will see so it doesn't matter which window you are using Powershell or command prompt uh both works but in both of the cases we don't have git now how will you get git it's very simple you can just go to the website right or you can just go to Google and search for git download now this is the website from where you can download the get the current version of git is 2.41 so we can get that one and it will ask you for which OS you are using now since I'm using Windows here we can click on Windows if you're using Mac you can go for that and as I mentioned before if you already have xcode installed most of the time for some reasons you install xcode even if you don't develop iOS application uh so do check if you already have git by saying git hyphen iPhone version if you don't have it you can follow the similar steps you can click on download there and you will get it for Mac OS for Linux you have to set the path and that should be simple so let's go for Windows here and once you click on that it will ask you for which version so basically you can go for a standard installer which is suitable for if you have only one machine but let's say if you want to move between different machines you can go for portable one but I prefer to go for a setup inside the machine and 64-bit because my machine is 64-bit so I will click on that so it's only 57 MB so depend upon 58 MB so depend upon when you're installing it which version you have you will get that now once you've got this download it's very easy to do the setup you will say click so given a prompt click on yes okay and we don't have a choice right we have to accept the agreement uh now this is a place where it will install git I will send next okay it says I already have get in my machine because I think I already installed it before but I will say okay I'll go with that particular folder that's fine with me now it also give you something called get bash now at this point will not be working with Git bash will be using normal CMD and uh anything else looks good click on next Okay click on next okay so it will give you certain options you know when you want to edit something and get which particular uh IDE which you want to use or not editor which you want to use now I will go for default one which is vim or you can choose whatever you want maybe let's choose notepad for this because series I don't want to confuse you with how to use Vim commands so let's use notepad here and click on next now this is this is something important to remember now when you work with the First Command of git it creates something called branches okay so we have this amazing feature of branch in get Now by default you will get one branch which you work with and they call Master Branch now when git came into existence way back the name was Master but recently again doesn't it doesn't look good right Master Slave so they went for an a normal word which you can use so we got main so if you can see we have an option of main here so I will go for let get decide and when we are creating the project we'll make it main will not be using Master otherwise you can change it from here as well that perfectly works I will say let get decide next and here you can see I'm going to use command line not git bash so I will go with that and click on next okay I will use open SSH and yeah open SSL so nothing to change much I will let you know when you have to change the basic configuration fast forward and merge yeah okay so when you say git pull this is what you do select I will say okay and next enable system caching required now it provides you some experimental features will not be checking at this point we'll click on install okay so it will take some time to installation let's wait for it you can as you can see it is installed I don't want to see release nodes I will click on finish and done we got the git setup now how do we verify of course when you open your command prompt or Powershell let's say here if I try to do that once again you can see it still says git is not a recognized command the thing is after installing git you just need to restart your command prompt and I will again open my Powershell of course you can search for Powershell from here and you can search for git version and you can see we got the Git Version so now git is properly installed okay now once we got the git installation now it's there right it's there in your machine but how do you make it your own every time you do git commit every time you want to push something you need to have your own identity of course we need to know right who is pushing the code because in git we have multiple people working together on the same project so whenever someone pushes the code on the server you should know who is doing it and that's where you need to have your own configuration the way you can check that is by saying get config and when you say enter okay you can see it will give you certain things now basically in git config there are certain things which are to mention at least two things one is your name your username and second is your email with the same email if you're using a public repository it's a git lab or GitHub you'll be having a public account right with the email ID so you have to use the same thing so if you want to know what are the existing variables we have so what you can do is you can say get config I want the global values and I want the list of values when you say enter okay so the thing is in my machine I already have this configured okay so this is not the first time I'm using get so I have these values but in your machine you'll not be having this value so let's do the setup how do we set the values here now since I'm using my personal email so that's why it is blurred because of the Privacy issue uh but yeah so you can use your own email ID there so how do you set a value it's very simple you can say get config so let me just clear this screen once so if you want to configure you have to say git config and then you have to say Global because you want to set it globally and then you need to mention user dot name and whatever value you have so let's say I want to set Naveen here enter so that is what is setting my name there next I want to set my email ID as I mentioned you need to set it at least two remaining we'll see later user dot email and I want to set my email ID and again for privacy issue it is blurred I will say enter and values have been set now if you can check the same command uh you will get your details there so that's how basically you can make this get your own now how do you create your first project as I mentioned before this not for just for coding you can use git for any purpose the moment you want to create something with people or maybe if you want to create something maybe you want to write a book maybe you want to write poetries or essays you can use get there and you can maintain the versions of your stories so once we have done with this setup so now we have GitHub in our machine right let's try to use get now the thing is normally as a programmer we use gate for different languages example let's say if I'm making a project in Java I can use git to create different versions of it and I will will be committing it I will also push that on some Republic repository and then in the world we don't have just one programming language right we have so many programming languages now if I go with any specific language here of course it will create trouble for others people let's say if someone is doing into JavaScript or python they will not feel comfortable with Java right and the beauty is doesn't matter if you're writing a programming language or a essay some lines of statement English statements it's all same forget it's not like get recognize the programming language and say hey for this programming language I will work in this way no that's not how git works it basically says you give me the file you give me the statements I will take care of it so git will not look for the code right so in this particular course we're not going to focus on any programming language let's say we are writing a code in multiple files doesn't matter the language so it's important for us to understand how do you store that file with Git how do you work with Git to merge different files so whatever lines I write it will be normal English maybe at sudo code for that matter but there this can be used by anyone even if you're writing a book or if you're writing a script for a video okay so let's get started so what I will do is first of all if you want to type something you need a editor right now in this particular course I'm going to use vs code because that's very famous uh so in my machine I already have vs code installed so let me open that so I got my vs code open here and I will just reduce the size of a bit yeah okay so this is my vs code uh you can use any ID for that matter and then in this I will just open up folder so this is where I will be working I will be working in general so if you open a folder and let me create this folder inside my user which is Naveen in this case and I will create this folder as first project of course this can be anything but let's say first project and opening it now imagine this as your working directory so what is working directory example doesn't matter if you're writing a book or writing a code you will put that in a folder this is what your folder is so you can say this is your working directory right and now I will open a terminal now as I mentioned before we need to do everything on a terminal right so if you are using vs query you get a terminal inbuilt or if you are using some other IDE or some other editors let's say notepad in that case you will be using your command prompt right now whatever we did before we did that on a command blocked here we are using a internal command prompt of vs code we call them as terminal here again same thing different terminology in fact you can also select do you want to work with Powershell or do you want to work with any other thing so in this case when I say terminal It Is by default using Powershell so that's fine we have tested this on Powershell it was working so let's continue with it basically if you want to understand gate you have to understand different areas in which git works now basically for get or not forget in general this is your project right so you can imagine this first project as your folder now whatever you do inside this git has no idea what you're doing okay you have to let git know that hey you know I want to track my progress I want to commit I want to create different versions right and to tell that to get you have to do something now basically apart from your working directory we have something called a staging area now staging area is a place where git knows okay in your project you have let's say 10 files out of 10 files you have five files which you want get to track now how will you tell that and that's where staging area it comes into picture you have to tell get hey whatever is there in the staging area please take care of it other files you can ignore that okay so staging area becomes important because that's where git Works apart from that we have something called a commit history as I mentioned for you can create different versions right and every time you commit you create one version basically and the beauty is you can go back of course I will show you those things but these areas are important so you are working with this directory and whatever you do in this directory git has no idea okay and if you say hey get do something with this git will say what you're saying bro so basically git has no idea what you're doing so you have to push that into a staging area how will I do that we'll see that later and then one more area we have is the commit history now how exactly all this thing looks like we'll see that later but you have Commit history where you have to do committing now this too which is your staging area and your commit history they become a part of a different box which is your git a lot of people do get confused between uh working directory and uh git repository there are two different things it's just that it looks similar so they say okay this is my git repository no this is different from uh the git repository this is your working directory okay so now what I will do is whatever files I have I will create here they have no so git has no idea about it right so I need to create a local repository here so when I say local it means it's there in this machine what if I want to share this with everyone else in the world or maybe I'm with my with my team in that case I will create a remote repository this can be done with the help of gitlab or bitbucket or GitHub your choice but those are the options we have now here uh we need to create a git repository or local repository the way you can do that is very very simple you just have to use a command kit as we are using first of all before we're going forward I will say Git Version and you can say this is a version right now if you want to create your git repository local repository you have to use something called init okay so once you do that you it will create a local repository in your project okay so before going this what I will do is I will use one more command now this command is very important which is called git status and we'll be using this multiple times so every time you want to do something you will use git status a lot so when I say git status it says there's not a git repository okay so we don't have a depository it says hey you are trying to run status but where is a repository as I mentioned before the folder here which is first project is your working directory if you want to use Git You need to initialize git so you have to say git init and this will create the empty git repository and now you have git here so where do we find it so you can see we have this path which is C slash user slash Naveen slash first project slash dot get now this is your folder of course this is a hidden folder but this is where it tracks everything so the staging area uh the uh commit history everything will be present inside that git folder and this is different from your working directory example whatever file you create here will be a part of your project but not part of dot get that's the important remember in fact till the end of the project or end of the series this is something you have to remember by default when you create a file it will be part of your working directory you have to let git know that this should be a part of git and that goes into staging area okay so now again let's do git status and you can see now git status works but then it says get status is on Branch Master oh now this is something we forgot to do remember when we were installing git I've mentioned that by default when you initialize your git project you will get a master branch but what we want is a means we don't want to use Master we want to use something else it can be main it can be a demo it can be any other name for that matter here we have the master we don't want Master but even if you have Master here it says there is no commits yet okay so we have not created something we have not done the committing here as well again what is commit we'll do we'll see that later but at this point uh we don't want this name right we don't want master so what you can do is you need to remove git now do we have a way to remove git here now we have to delete this folder so you have to delete dot get okay so we can say RM hyphen RF and we can say delete git okay it says it's why okay don't have sufficient rights okay that's fine I will just delete time from outside okay so how do I delete that so what we can do is here we can we cannot say hidden folders right so let me jump to that folder okay this is a folder right now here we have dot get we can simply shift delete and gone now if you try git status you can say it will say not a git repository and now let's initialize it now the way you can do that if you say git in it it will by default give you a master we want main right in that case you will use something called hyphen B and Main so basically now you're saying that so again what is we'll talk about that b later when we talk about branches but here we are trying to say that whenever you initialize this project make sure that you have the main name not the master when I say enter okay it says initial empty project created or empty grid repository created and now if you say get status you can see the branch name okay so it's revealed right so the hyphen B is Branch here so branch is main not master in this case and we are going to continue with main till the end of the course now once we have done with the initializing of the project or initializing of the get how do you add files that will say in the next video so basically we were able to create a project here of course we got a empty folder which is your working directory and we also able to get the git in it remember we have we got a main branch we have initialized the gate project now basically the way you can check if everything is working fine you can say git status and we are doing this from last one video right so git status will give you the status of your git project it says on Branch main that means we are on the main branch now of course in future we'll see how to make a different branches and it says there is no commits yet so of course we have not done the commit yet and then the project itself is empty now what I will do is I will create a very simple file now the thing is it doesn't matter what type of project you're working on a software project or a book project you do create different files right now I don't want to go for any language specific things here related to programming let me create a general file and let me name this as my first code dot txt or txt so instead of going for DOT java.c.cs which is C sharp.cpp let's go for DOT txt now this can be a coding file as well it git forget everything is same it will trade txt as any other file okay so what I will do here is well I will write a very simple statement and I will say hello world okay so that's it nothing much a very simple line in my first line of code now the thing is this project or this file is there in your working project right if you remember we have talked about those different areas right we have a working area so working directly where this is where you edit your files and as a programmer you work with but if you want git to handle this you need to add that in a staging area if you don't do that what happens let's say let's try now here what I will do is I will say again git status it says there is a untracked file now the thing is if you want to commit something if you want git to take care of some files for different versions you have to give that to git and the way you can do that is by adding that particular file to this staging area now at this point we have not done that and that's why it says so let's read everything so it says on Branch main that perfectly makes sense no commits yet of course we have not done the commit yet but it says there is a untracked file okay there might be multiple files but here we only have one which is first chord dot txt okay uh it says nothing to add to commit but untried files present okay you know what happens let's say we have this file and now I want git to handle it now the way you can add it to the git by using something called a commit right so we use git commit imagine git commit as saving something but then git will not directly save this you have to make sure that you add this in staging it that's what it says here now if you want to add a particular file to the staging area this is what this is the command you have to use so what is a command it is get add so that's the two words you have to use git add and then you have to mention the file name the file name here is my first code dot txt okay and when I say enter now this is added in the staging area and now once you have done that let me just clear the file or clear this screen once you have added the file to the staging area when you say enter now you can see it says something it says on Branch main makes sense no commits yet of course but then it says changes to the committed it says there is a new file added called First Code now is it available or is it committed not yet this is not committed yet it is just that this is into a staging environment yeah if you want to unstage it you can use something like this you can say git RM cached file uh you do on stage but we don't want to unstage it we want to commit it now how do we know that we have different commits as I mentioned before it also maintained the history right so whatever work you have done so let's say in your project you have till now you have done 50 commits and if you want to know all those commits you can use a very simple command called git log so with the help of git log you can see all the initial comments and you can see it says your current Branch main because that's my main branch does not have any commits yet so that means the file is there in your working directory the file is also there in the staging but not in the comment history now to achieve that to commit this we have to pass another command and that command is very simple which is the commit okay so the thing is one of the question you might be having okay so once we say commit it means it goes into the local commit right but how many times we should we should do that and after how many files edit so normally let's say if I can think about my project and if I'm working on one feature I will be thinking okay once I complete this feature I will say commit right so that's why the project will be stored that's not the case actually it depends upon a lot of different factors you don't work alone right you work in a team so sometimes your company defines how do you how should you commit how often you should commit uh your company defines what type of passages you should have that's right so for this commit you have to also pass the message so for this particular series we are not going to see when to commit it's just that we have to understand how to become it again when to commit is something you need to decide based on your project but then and it is a common saying commit early and commit often right so we are doing committing here now if you simply say git commit you can say it will not okay it is giving you some message here please enter the commit message for your changes and blah blah blah okay so what I will do is I will just edit uh go back because this is the web okay so about in a commit due to empty commit message basically commit has not done the thing is when you want to commit you have to make sure that you also pass a message of course right every time you commit something you have to specify what changes you have done there so I can say uh if you want to add message you can say hyphen M and then you can pass a message my first commit now of course this type of messages should be logical it can also defines what features you have added maybe you have resolved some bug you can mention that there or uh I have seen few projects or few companies they also follow something called issue tracking so let's say if there's an issue created or some tickets created you also information the ticket number which ticket you have resolved okay something like that and when you say enter now it says one filed change one insertion that's right so basically we're able to do our first commit here so this is your first commit it says create a mode this is the file name and now this is getting tracked by get okay cool uh after doing this I will say git status and now it says on Main Branch nothing to commit working tree clean okay that's good now if You observe there is one thing here which I intentionally missed which is this part what is this number that looks weird right see the thing is git also provides you something called Integrity it means once you save something in a git commit you cannot change it without get knowing about it so basically every time you want to make a change git will know that something has been changed how it basically follows something called a checksum now checksum is something imagine checksum as a fingerprint for the data so example if every time I change something in the data it will change the checksum as well okay even if a small change in your in your code will change its exam and git creates a checksum for every commit so if you try to change something here in the commit itself because of course a local file right if you make any changes it will come to know that hey it's not matching you have made the changes but I don't have any idea about it so I have the older version so basically checksum is very important now this is done with the help of sha1 and it creates not this number of characters it creates 40 characters okay out of which we only focus on the first seven so if you can see these are the first seven hexadecimal numbers so we got fd914 D5 of course when you do it on your machine you will get a different number right because this is unique to this particular data but behind the scene this is not seven This is 40 characters to display it is only showing the seven characters here okay now since we are have done our first commit let's try git log so git log will give you the log of all the comments when I say enter now you can see it gives you it shows something it says okay what I will do is I will just clear the screen so that will only see this particular message okay so let's see what it it says it says there's a commit okay makes sense and who is the author for this commit this person Naveen and that's my email ID which is hidden which is blood and this is a date so this is when I have done this commit and now when you see different commits here there is also something called header now this will make much more sense once we start working with branches but at this point uh we have head to Main and the message is my first comment the more commits you do you will see though all those things coming up there and everyone have a different commit and this is the 40 characters thing I was talking about so that's 5 10 15 or this must be 40. okay so we only say first seven right if you can see up here so when we created this this was the first seven characters but it's matching with this the first seven characters right but then this is in general or behind the scientists 40 characters now that's how basically you do your first commit so we are done with the first commit right and when we say git log we got this particular commit here and we are happy with it right we got the first comment basically so what I will do is I will make some changes let's say I want to add some exclamation marks here okay so when I do that and if I want to uh let's say I want to do the get status and as I mentioned before this git status will be using a lot so when I say get status it says oh get status on Branch everything is clean maybe the file is not saved okay that's the issue so you have to make sure that you save the file because even git is not sure what you have done so every time you make some changes save it in your working directory first and now if you see it says changes not stage for comment basically there's a file which we have created and now this is into a modified stage now that's right the thing is every time you make a change or let's say every time you create a file it is into working directory right and then you try to Stage it so that goes into the staging area so we got a working directory then we moved that to a staging area and then from the staging area we do commit so that it will go to the local commits right so those are the steps which we take so before making these changes we had data in the local commit and then it was then the staging as well the moment you make some changes now it goes into again a working directory now this is not stage example how do I know this is not staged example let's say if I do a commit now so let's say if I'm doing a commit and this time I will say this is my second commit uh of course this is not a good way of writing message but just for learning purpose we are doing it so when I say enter now you can see it says changes not staged for comment basically if you want to commit something the data the file oil should be there in the staging area this is not so that's important so every time you make a change add that to staging area then move that to the commit now how do we add it we have done that before right we can simply say git add in fact let me just Square this coin so I will say get add and then I will say first code Dot txt and then when I say enter okay so now this is into a staging area and now once we move that to staging area I can say enter and now we have done with the second commit so in total we got two commits okay if I do a git log to check how many commits I have so you can see we have two commits here this was your first Commit This is your second commit and of course with every comment you get the message there you get the time uh which is mentioned here and then you also get the author who has done that so maybe if you are working in a team you are doing some collaboration so you will also know who has done what commit and that's important okay so now uh this is where my head is now the thing is imagine head is a pointer so even if you have multiple pointers in your local comments as I mentioned local commits I have multiple uh it's basically multiple comments right so you'll be having a pointer which one is the latest one or which one we are pointing to so here we are pointing to this one and again we'll focus this more once we move towards the concept of branching okay now what do you think if I have one more exclamation so what's the step first save of course it becomes a modified version so it is not staged and you can see it we also get a message here or not a message but on the in vs code especially if you are using some Ides which supports get in a good way and vs code does that and you can see it says M which is your modified and the moment you add that to your staging you will this will be gone but what if of course staging is important right so from working you move that to staging from staging you move that to commits but what if you want to directly commit something like this let's say I want to do the commit and I will say this is my third comment I'm very bad with comments but this should be something like added exclamation mark or a solved a particular story or if you're working in agile methodology but here let's say I have this particular commit and now I want to do the commit without staging can we skip staging and we can if you want to skip the staging part you can simply use a hyphen a as an option so say git commit hyphen a then hyphen M for the message and then you can pass the message basically you are skipping the staging thing so if I say enter now you can see the commit has been done without going into staging area Okay so that's important if you don't write hyphen a without staging it will say it is not tracked so if you if you want to move from the working directly to commit this is how you do it okay now if I do git log once again to check everything is good so you can say we got three commits uh this is the third one recent one and if I say enter you will see also see the previous commits so this is how basically you use a to move the file from working directory to the commits so let's try to understand the diff command so basically in git we have this option of finding the differences between what you have worked and what is already there in the comments so let's say if I make some changes here so what I will do is I will first of all check the status of this and you can see there is nothing in my uh staging or the thing to track and I will make some changes now so if I say hello world so that's the greeting and then I will say take input from user and add the values so let's say I'm writing a pseudo algorithm here and when I say save and if you can observe especially in in vs code you can see this green line This basically means you have added something okay in the file and now if I go back here and of course I can simply do a git status of course git status will give me the changes here but what are the changes I mean of course git status will show you that this product file has been modified but what exactly is modified I want to know that so what I can do is I can say get and I can type something called diff now when you say git diff and when you say okay when you say enter it will show you the changes which happened in the file and these are the changes you can see it says uh there have been few changes the number of lines now this are the number of lines which you have added so we got hello world in fact there's a change here as well of course we have not changed here the only thing is I said enter right that's a new character now now basically this is the older one and these are the new changes now if you want to see okay I'm doing a commit it says it is untracked I want to know what changes I have made so you can use something called a git diff so basically it will check the comment it will check what data you have in your working directory and then it will track the changes and now once you have done that maybe I want to add this so I will say git add first code Dot txt and enter enter and now once you have added let's say git diff now you can see there's no difference the reason is now this is not into a modified this is into a staging right now once you move this to staging I can also comment but now what if I want to find the difference I have added that to a staging area and now I want I want to find the difference in this case again you can do get diff but since we are into staging I can say hyphen iPhone staged and now you can track it so if you have your file in the working directory and if you want to check the difference you can use get diff which is differences and if your file is into staging area then you have to use hyphen iPhone staged to check the changes because it's already into staging area once we know the difference we can simply do the commit now and of course for commit we have to pass the same thing we have to say git commit and let's say I'm basically working on a project where you have each task given us number a story number so I can also say story 3.1 and I can say message is user input so basically that's how you can mention some messages which should be logical yeah and now if you see git log you can see the entire history so this is the recent one which you have done uh and then this is the this is your third commit and if you go down you will you will find more let's try to understand how do we remove a file from a get repository so let's say you already created a file and then you have pushed that Target repository and now you realize oh that's not the file I wanted to put that into git repository now why you will not put something in the git repository now think about this you're working on a project and you have multiple files and one of the file is basically where you put your credentials let's say I create a file here so this is where I will put all my password just for my references so I will say all my credits.txt and this is where I will basically put my username password so I will say username is nvn 02 and my password is rdy03 so this is my basically username and that's my password and I just want to save it for my reference so that I can just connect with the database or something and I want this to be only in my particular machine I don't want to push to the server right and up after this let's say we also have some readme files so we've got redmi.txt or readme.md basically we have a concept of markdown you know if you want to make some document beautiful we can use markdown to make it more beautiful that's what git uses so basically we get readme.md and this is an important file in in every project so we'll also see that and okay so you can see we got you here which is untracked basically so let's say in immediate me I will say this is my first project author is Naveen ready company studies score okay so let's say we have this values here credentials we already mentioned and let's also do some changes in the first code in the first chord now you want to submit data to the database so let's say we have all these changes in the code okay this is Imagine This is a coding file of any language which you love and we have method changes here and now what I will do is I will just see the git status when I say get status you can see it it is showing that you have one modified file and that's correct we have done the modification and you've got two files which are basically untracked and that's why it says you can see if you see here we have U which is untracked okay now I know what to do in fact if you do one status once again you can see there is an option here as well no changes added to the commit use git add or get commit hyphen a so hyphen a is basically an option of adding directly in one line itself but let's say if I want to add all the files in the staging how will I do that of course uh if you want to add all the files you can simply say git add and mention each file so this is firstcode.txt then you say enter again do it for the next one or what you can do is there is a shortcut you can simply say dot now dot simply means you can add all the files in the in the staging area enter and done now all the files are being tracked so you can see now it says a which is added and if I say get status now so you can see we got a new file two new files and one is modified one and if you want to make the changes you can simply say git commit hyphen m and you can pass the message you can say read me and story 3.2 okay so let's say I'm adding this three and then you can see we got the files in the database now but basically a git Gator database now if I say get status what happens if I say get status it says everything is clean nothing to commit and now everything has been tracked in the git repository that's cool right but then the thing is I will now after working for let's say a few hours I will decided to push this to the GitHub repository or some public repository now at that point what happens is everyone can see my username password I don't want it basically I don't want this file to be there in my git one way you can do that you can just right click here and you can say delete move to trash and done your job is done but the problem is if you say git status it's already there it says it is deleted but it is deleted from your working directory not from your git right so one thing you can do is you can say but if you do git commit that's that's tricky now right so what was the idea here is don't delete it from here because I get status everything is clean don't delete from your working directory you have to delete first from the get and the way you can do that is by saying get RM that's the command you have to use and then you have to mention that which is basically cached so we have to say cast and then mention the file name which is credits dot txt now when you say enter it says removed and you can see now it is untracked so basically first you have to delete your file from the get now it is on track and you can happily delete now delete moved and now you can say get status everything is cool you can say changes to the changes to be committed so I will simply say git commit hyphen M remove the credits file and done so now you can see we don't have anything here and we don't have anything in the git and that's how basically you can Safeguard yourself from your unexpected file uploads now if you remember when we talked about git we have mentioned there are different types of repositories right now basically when you can have git tool which is a distributed Version Control System you have a commit history in your machine right and then of course you can jump between the commits but what if you want to collaborate with everyone so let's say you are working in a team and then they are working on some feature you are working in some feature how will you collaborate and that's where we have to use something called a remote repository now what is a remote repository so example let's say we have six people in the team they have their own machine they have a local copy or local repository and now if you want to share it we need to use some remote repositories some server which will be public so that they can fetch and they can do something of course this can be a private to the company or this can be public so that you can access it from anywhere but let's say at this point let's talk about public because we're not working for any organization where the security is most important we are learning it right so let's talk about the public here now there are different options we have in fact uh the options which are talking about they also provide you something called private again we'll see those options there uh okay so we have three options here there might be multiple repositories but a multiple remote repository options but here uh the most famous is GitHub then we have git lab the second one and then third one is bitbucket now bitbucket is given by atlassian which is a very famous company they provide different tools for the developers so you can use this and few companies are using it most of the companies who want to use the private features the paid private features they can use gitlab or they are using gitlab basically and then for the public for the normal people or for the public we have something called GitHub now GitHub also helps you to create your own profile and that's why if you go for the interviews or if you talk to people they will say hey give me your GitHub profile it's not like you can't work on gitlab or Bitcoin it's just that GitHub is very famous among a normal public so we are going to use GitHub here of course you can switch to any repository your choice but let's talk about GitHub now first of all you need to have your account on GitHub okay so how do I get that it's very simple click on sign up enter details here whatever email you have and uh you can log in once you are signed up you have to also make sure that you're logged in and let me just do the login First and I'm just hiding my email ID there so that we can keep it privacy and here we go so I'm trying to log in and that's my GitHub repository okay so I have a lot of repositories here because when I did something I also pushed that code on GitHub so that you can see and you can see all the repositories here there might be some private repositories which you cannot see but that's how it is okay so we have some repositories here now what if you want to create one now first of all how we can use GitHub it's very easy let's say if you want to search a particular project uh so what you can do is you can search for something example let's say I want to search for Linux kernel which is a very famous uh repository so you can see this is Linux the Linux kernel which we use it is open source and the entire source code is available here now the owner of this is Linus which is Linus Tower World everyone knows it right so you can see uh this is the entire code of Linux and you can get this on your machine okay it's very easily now it also analyzed the entire code base it will tell you which languages it has used so you can see 98.4 percent of this code is C uh some shell script some python script and make file so these are the languages they have used contributors you can see more than 14 000 contributors we have for Linux and you can see these are the some options so at this point when I'm recording this video there are eight thousand more than 8 000 people are on this page okay so that's interesting everyone want to look at the code and they might want to modify it or they want to add some new features so basically for the project you can also give Stars example if you like this project you can give a star here or when you create a project people can give you star and that's how you become a GitHub star uh otherwise or you can pay some amount okay I'm just kidding so so let's say we also have option of forks here uh now example we will talk about what is Fork later and this is 48 000 Forks already happened here so it's called I can get this code on my machine it's very simple you can click on this code and you can click on download zip okay and you will get the entire source code but we are not going to do that options we have two options here which is https and SSH we are going to do this but how will you use this it's very simple now when you have this project what you can do is or for this even to browse this you don't need a GitHub account I'm uh if I'm not wrong uh you can get this you can simply copy this okay so you can copy the link okay first of all we have mentioned the option right download zip that's one option second is you can copy the link and you can go to your terminal and here you can pass a command which is git clone now clone is basically copying something right so you have a code in the repository and now you want to copy it so you can say git clone and you can mention the address and the moment you say enter it will copy the entire Linux source code on my machine so you can see it is downloading it will take a lot of time because I think it's it's heavy I've never tried it or maybe I've tried it before but never completed the entire download you can see even with this speed only two percent completed and that's the entire size so I don't want to do this I will just cancel this okay I don't want to download the entire stuff I just wanted to show you how do you get it okay so that's how you can copy uh there are different options here we have https and then we have SSH okay so we'll see later how do we use this but at this point you can see we have some repositories but what if you want to create your own repository it's very simple if you can see let me just increase the font a bit yeah so if you can see there is an option of plus button so I want to create my own repository we have done that for the local machine right so when you say git init it creates a local repository in your machine now I want to create a remote repository for that you just have to click here and click on new repository click on that okay it is creating yeah now this is the page you will get now that's my ID GitHub ID and this is my repository name so let's give a name to it of course the repository should have a good name and we have done that for our own machine as well right example when we were doing vs code remember we created a project and that was your repository name as well here let me create something so I will say git course because that's what we are doing and it is available so again this is not publicly checked it will just check do we have in my account so I don't have this name in my account so I can use it you can give a particular description here so you can say git course demo and then you can make your repository public or private now Linux we were able to search it because it was a public repository now let's say if you're working on a project and you don't want to share the code with the entire world of course at that place you will be using a private one so of course you can share the link with your friends or not for the friends but with your colleagues and then you can work on it public anyone can search on GitHub so for this I will keep it public so that you can also see the repository later when you're watching this video and then there's an option of add a readme file so at this point I will not do that now readme file is important is because let's say if you have built a project and if you want to mention some steps what is this project how do you run this project uh how do you contribute so all these things you can mention in the readme file but at this point I don't want to add it there's also option of git ignore which we'll see later and then you can choose a license there are different licensing option here if you want to keep it open source and if you want anyone to use your things at this point I will not choose any license and click on create Repository and done so you can see you've got your repository here now when I'm recording this video there's an option of co-pilot for AI programming and I will not be using that also I can invite collaborators at this point I don't want to do that just scroll down and you will see all these steps now first of all certain things which is very important you can see a link here now this link will change based on where you are clicking so if you are clicking in HTTPS this is what you will get and most of the time when you're downloading URL or some repository you will use https but we will use SSH so the advantages okay let's talk about those Advantage later in some time so let's say we got this link here just try to remember we get we do get a link a unique link for your repository this is unique now how do you create how do we work with this repository now one thing to remember we have a GitHub repository which is on the internet somewhere I don't know where it is and then I have a local repository what if I want to make some changes how do I do that how do I push the code from my machine to the local repository or to the remote Repository now to do that what I will do is I will open my terminal so my terminal was already opened it's clean first of all let me create a folder here and let me name this folder as git course okay say an import with my remote repository and then I will jump into this particular folder the git course and I will say I will check do we have any folder here you can see I don't have any files or folders okay first of all I'm into Mac so LS there's no folder that's cool now what I do is I want to create some files now first of all we don't have any file let me create one file now it can be any file okay and you can simply follow this steps here to do that I want to push one file from my local repository to the remote repository and you can simply copy paste and run it will work but let's try it one by one just to understand how it works so the first thing that we do is we will be using we will be getting a file which is readme file remember we have talked about redmi so to do that I will say eco and I will push some data here so I can say git course demo and I can type multiple lines of data here but let's say we have single line and then I want to create a file called readme basically this is a command Eco is a command using which you can Echo this message to this particular file so we will say readme.md now MD is basically stands for markdown if you have a design some redmi file and it should look good so you can use something called markdown okay and you can see if I say LS now we got a file created and if you want to see the content of that file you can say readme.md and you can see this is the content so using cat command I can just see the content so I do have a Content now so LS we got a file the next thing you have to do is we need to create a git repository the local copy okay the local git which is not done yet because we got a folder but it's not get enabled so to do that I will say get init and we can follow the steps or otherwise we can also create a branch name because by default it will create master right we don't want Master we want main but let's follow the same steps so you can say it has created a empty repository and that's done so let me clear this we got a repository as well if I say LS you can see we got we should have got the folder I think it's hidden so yeah so you can see we got a folder here which is dot get now this is where it will have uh all the folders which we have talked about before so this is done the next step is we need to add because if you say git status now we got a file but that is not a path so it is a untracked remember we have a working copy then we have to Stage it now how do we stage it we have done that before so it's a git add read me dot MD so now we have staged it now after staging if you say git status you can see we got a new file and this will be committed now how do we commit it's very simple you will say get okay I'm just trying to copy the code from here okay so on the left hand side you can see we have the code or the commands we'll say git commit will mention hyphen M for the message and here I will say first commit enter so that's my first commit right but again this commit is happening in my local machine so that's done next we have to create a branch so I will say git branch okay now why do we have to create a branch here the thing is by default we got a master Branch right and we have mentioned before let's not use Master let's use something called Main and that's what GitHub is also promoting so I will say Main enter and you can see now we got a main branch okay now once we got a main branch what next it's time to connect to the remote repository now this is a local repository we need to create a remote repository but the problem is how will you connect your local depository to the remote repository now that's a big issue so we have to search something called an SSH now how do I do that now basically there are two options one is https you can also get the steps here and you can see something is changing here if I click on SSH things are changing the advantage of using so first of all when we use https basically to push anyone can push right this is my remote repository you can also push how do I know that who should who should be allowed now that's where when we use https it will ask you to log in so if you are saying you are Naveen how do you prove yourself so it you have to login otherwise you can use SSH the problem with login is you have to log in every time what if you can just set up your machine once with a key and then every time you do something it will automatically detect who you are and that's why you have to set up the SSH now the way you can do that is by using very simple thing which is SSH Keygen hyphen o this is the command you have to use SSH hyphen Keygen space hyphen o now this is the only time you have to do it okay you have to do it only once it's not like for everything you have to do it for one machine you have to do it only once okay I just messed up there so I will say SSH kitchen hyphen o enter and you can see now it says generating a public and private key basically that's how you create a key to communicate between the client I mean your local copy and the server so it says enter the file name in which the file will be stored I don't want to mention anything here it will go for a default name I will say enter oh the thing is in my machine already have this created I will just overwrite I will say yes you will not get this option if you don't if you have not done this setup before now it will ask you for a passphrase I don't want to mention any plus phase it's like a password enter don't want to mention anything and done I got my file created now where will I find this file what I will do is I will just go back to my folder and if I say LS in fact LS hyphen a okay first of all we got SSH created this is not the SSH okay let's see the SSH where it is so if you can see this is the folder which we are concerned about this is where it went so I will just go to that folder using CD space dot SSH enter let me just clear the screen and now if I say LS hyphen a you can see we got our published here let me open that so I will say get ID dot Pub and we got the key right this is where you will find your key in the pub now where do I use this key we got the key here right but how do I use it it's very simple you can just copy the entire key okay copying is done where to paste it it's very simple if you can see here let me click on here I don't want to lose this page so I will just open a new tab using the controller command button I will click on settings and you can see setting is open here and then if you scroll down there's an option of SSH and if you see this I already have some keys here ignore that I will click on new SSH key I will give a title to it git course one because I already have one before another paste your key that's it and click on ADD SSH key and now your client and your server is connected so connected is not does not mean it's continuously connected every time you push something it will verify okay it's coming from a right person because the I can see the SSH key which is mentioned here and on the local machine they are same okay so now once we have done that in the terminal let's go back to our folder so which folder we were working with I think git goes yeah and if I say LS hyphen a just to verify and you can see we have the same thing now if I go back to my steps so we are done with this step right branching now we'll just use this particular one and that too for SSH okay so I will just copy this and paste it here now what we are trying to say in this is we are doing git remote because that's a remote repository of GitHub we are adding a origin with this link so this is where we are trying to connect and when you say enter connection done okay so basically we are trying to map it once you have mapped it now we have to move this file which is in the local repository because this is in local right the remote is empty at this point so what I will do is to push the code just copy this paste so what we are saying here we are saying git push push means we are pushing the data from the local copy to the remote copy and then we have we are also mentioning that there's a different branch and uh position so basically U is Upstream setup set up the upstream and then the branch name is main okay this is something you have to remember sometimes you will mess up with Main and master if you're referring to some other documents in the earlier documents earlier versions people used to mention master and now we are mentioning main so you might get confused there and if I say enter it is pushing the code okay it will take some time but before posting it is verifying hey the key is there is the right key yes I think I I only have one key here enter and done the pushing is done that's what it says uh it says counting objects done total uh done set up to track okay looks like everything is done how do I verify I can simply refresh my page and we got it now this is a file which we created in the local machine right and if I open this you can see this is the data we got okay now this looks cool right so basically we were able to push the repository from the local machine to the GitHub and every time you work on a project now these are the steps you have to follow so basically we were able to push the code from our local repository to the remote repository right and then we followed some steps and it is done now that was your first commit right but what if you want to do some more you want to build the entire project and you want to push of course you will not do it from normal command prompt you will be using some IDE to build your project now this can be for Normal book writing as well or making a video script as well but let's stick to vs code here so of course you can use any ID for that matter or any editor so if you're using a normal notepad of course you have to use a terminal command prompt external to your editor but since in vs code we have created editor as well and then we got terminal so what I will do is first of all if I want to use vs code I have to open that folder now which folder now if you go back to terminal this is where we are right so if I clear and if I say PWD which is present working directory I am into this folder which is git so so whatever files we have here is into this particular folder which is git source now I will open that in vs code so I will click on file I will say open folder Etc Naveen get course open so basically I have opened the same folder okay so we got that file here right so if I open this this has the same content which we had earlier but what I will do is instead of working on this file let me add some more files of at least one file so I will say let me say this is my user service dot txt now basically let's say if you're building an application the reason I'm doing txt is because it can be any programming language right Java python c-sharp it's your choice so let's say if you're saying user service we are building an application where I want to do something with user service maybe I want to accept user data I want to process some data on it so let's say user service and here I will say get the user data so that's it nothing fancy just one line of code in fact this can be a normal programming code as well but just to keep it simple for all the languages we are using a normal text so we are saying get the user data and save now if you see this this particular file is there in your working directory it is not even that in git and also this file is not even there on the GitHub this is what we want to push on GitHub how will I do that so let's go back to vs code and if you want to do any any of this we have to say new terminal and we've got a terminal here and here basically we have to say git status now when you say git status you can say we have a git repository inside this particular folder but this file which is user service dot txt it is untracked we need to track it so how will you do it it's very simple uh to track it we can simply say get add and you can mention the file which is user service.txt enter and now we have added that into staging area How will I know that let's say git status and you can see now it's into staging area and we can commit it how will I commit get you know at least I think at this point you remember all the commands so it's a git commit hyphen M and you can pass a message so you can say user service created now it's always a good idea to type at the same time when you're watching this video so that you will know what is happening right so here if I say get commit and now we have committed it and that's why you can see that you here went off now okay committing done but does that mean it is available on GitHub no we have done the commit on the local machine right now we need to push it on the GitHub and for that we have to remember that command git push so let's use git push and then you have to mention origin so basically for pushing you have to say push and the origin is the URL remember the URL which we have used before that is what is representing this origin and then you have to mention the branch the branch is main we are pushing on Main Branch I will say enter it will take some time and done you can see pushing is done so from your local machine to the GitHub let's verify go back to GitHub now we're still not here refresh and you got it so you can see we got this file which is userservice.txt and if you open this you can see we got the data which it says get user data it is available now right so let's get back to our project this is these are the two files we have and if You observe we have two commits here now what are the two comments if I open this two commits here this is the first commit which we have done where we created one five which is readme.md and this is your second commit which is user service created now you can actually at any given point you can go back to the earlier version where you don't have let's say if you don't want user service I can click on this particular file and it will give you the status of that commit so in the uh in the first commit we had only one file right that's what you can do so it's it's fun to navigate between different commits if you want to go back to any commit and if you want to see what changes you have made uh in fact you can click on the file as well to see the changes so if I go back here and if I mention if I go back to any file okay let's go to commit and click on any commit here so it will mention what changes you have made so we have created this file which is readme.md and this is the change you have made in fact you can go to the other commit as well which is here and you can see what changes you have made of course it makes sense when you have multiple files and you can see all the files which are changed okay so that's how basically you add your files to the remote repository let's talk about tags now what is tag we'll talk about that later but before that I just want to show you one more thing which is about this remote now if you remember in the earlier video we have done this push right so from the local machine we were able to send the data to This Server right so basically we're able to push it now it has four things first of all we have a git command of course because we are using gate tool next we have Push basically we are pushing the code right whatever data you have and then we have something called An Origin here okay so we'll talk about origin because that's very important for this part then we have we are specifying the branch name so it can be main it can be mastered or any other branch which you create let's talk about this origin why it has to be always origin of course we have done origin but it can be different as well the thing is for this particular repository what we have done is when we talked about the remote server we only have one example if I say get a remote hyphen V so this this is the command using which you can see which is your origin so we can have a origin for fetch so from this server to client this is the link we have to use and from client to server again we have the same link because we only have one remote repo there and by default the name is origin of course this can be any name you can change it as well so you can rename it or you can connect a different repositories not just one and you can pull and push to any other repositories if you want the only thing you have to do is you have to change this one so instead of pushing it to this then you can push it to some somewhere else okay so keeping that aside now let's talk about tags now basically uh we have a concept of tagging now if you have observed every software which we use it has a version number example I'm using vs code here and if I go to help and if I click on or not not help here because in Windows you will get that in help in Mac you will get that in the about so if you go to about vs code here so you can see it is giving you a version number here so every time you you down to the software you will get a particular version of course you will also get the updates for it so you can simply go here and I can check for the updates so you can see it says restart to update but I don't want to restart now but you will also get update there so the current this is the current version and this is a commit now this looks weird right why do we have a commit in the about that will say in some time and also observe some things because in the next video we'll talk about this thing in detail okay so we have electron we have chromium we have node.js and all these have versions okay so we'll talk about it in some time but important is we have a version here now this version is basically a tag so let's say if you're working on a project and then you have done several comments and now you think okay I'm all set to release my next version so you can give a tag to it and then one stack that once that version is done you can go for the next version so basically how do you give this tag the version number to each commit so not exactly each commit let's say you have done 10 commits and then now you think okay the software is up and running we can publish this but particular product to the users we can give it a tag first of all how do I check how many tags I have for this project now the way you can do that is by using something called get tag and when you say enter it will show you all the tags which are given till now for this project and this is empty is because we have not given any tag so let's give our first tag here how will I do that it's very simple you can say get tag and then when you say tagging there are two options here one you can use the annotated tagging or you can use lightweight tagging now if you really want to release this to the users and if you want to give more information about the user I mean who is committing it or who owns it so if you want all those information use annotated okay otherwise you can go for lightweight which we're not going to see so let's see annotated here where every version will have different uh information about it so for that we have to use a hyphen a as a option for the annotated one and then now you can mention your tag number so basically these are your budget number so there are different ways of using version number some people simply go with 1.0 like this version or you can also mention V here so V 1.0 so we can go with this particular one which is V 1.0 this is our version which you are specifying here and then you can also provide a message in fact we need to do that otherwise git will open a editor which will where you have to mention this otherwise let's say m to give the message and I can say first release so you can give something like this as a message and when you say enter now tagging is done so you got the first stack now if you want to check you can say git tag again and you can say we got one tag here and of course uh you can also see detailed information so you can say git show V 1.0 now this will give you description about this particular tag and when you say enter this is what I was talking about so for this particular tag here uh this is the tagger who has given the tag and then so that's my name and my email ID which is hidden uh so the commits which I have done here is this is the commit which we have done and this is it so I have done this so okay first of all let me just check all the thing done okay so if you see here we have done the tagging right but the tagging is available only in my machine in the local copy so every time you push example let's say if I do some changes here uh I want to say this is get user data and I will say process so basically we have done some changes right process the data so we have made some change to the software and now every time you make a change you can say git status you will get the status what's the next step okay so we have to add so we have to say git add user service.txt what next again we can say git status uh it says now we can do the commit let's do the commit here so we'll say get commit hyphen M and you can give a message now I can say uh processing user data so we have added the new feature right so let's do that and of course in the real life project it will be a bigger code which just trying to keep it simple enter committing done but the commit has happened only in local machine we have not done on the remote because if you see this is a local one right if you go back to your remote uh and if I go back to git course you can see we have done the commit yesterday so basically I'm recording the video One in a day so we have not done the commit here so if I open this we only have get user data we don't have losses user data so we have to push right how will I push from my command line uh I can say get push origin main right this is the command you have to use and when you say enter so it will try to push now and that's done so pushing on the server done let's go back and refresh so you can see it says now and this is a new commit which we have done and if you see the data we have added new line okay so this is working right but then if You observe on the server there's no tags here you can see Zero tags in fact we before the commit we have created the tag in fact you know after the commit we have done the changes right we should create a new tag here now which is we a 1.1 this is a new tag and we'll say a message we can also do um daily release right 27th June release so normally you know a lot of companies that release their product in six months or one month let me do it every day so I will say enter now so we got a new tag How will I know that we have different tags here so we have seen the command right which is git tag now you can see we have two tags but if you go back to this server we it shows zero tags here so if I refresh zero tags so what way to do is when to push the tags as well separately we cannot simply push the code and it will have a tag no you will not get that so what I will do is I will say get push origin and we have to mention the tag so let's push the 1.0 and that's done so you can see the new tag is created and if I refresh you can see we got one tag and if I click on this tag this is a version one and if I see uh this so in fact you can download the source code and it happened four minutes before right okay so it will give me the source code itself okay we don't need the source code okay but you got the idea right so basically we can jump between different codes based on the tags as well and now let's see let's also push the version 1.1 so we got two different tags and if I refresh you can say we got two tags here and based on which tag you have you can download it so this is five minutes before and this is one made before so different tag will have different codes okay so you can see this is first it is and this is the 27th June release awesome so this is working this is how you basically work with the tags so till this point we were able to work with our own repository on GitHub and local as well but what if you want to work with some other repository maybe you want to clone the code and you want to see what is happening there or maybe you want to push or you maybe you want to do some changes and use it for yourself or push it to this remote repository again how will you do it now first of all let's go let's find some project now since we are using vs code which is open source so what we can do is we can go to GitHub so you can do a search here which is vs code now if you search for vs code you can see you will find the source code this is the source code which has so many stars here and this is from Microsoft so let's use it now this is the actual source code of vs code now the version which we are using is 1.79 remember when we were doing the last video if you go back code about so this is the version right 1.79.0 so the current version they have is what so you know every project will have a readme file you can open readme file which is here it will have some updates right otherwise you can just go here and you can look at the commit history as well so this is the commit history and you will also find tags here okay so if you go back to code and if you see tags so you can say this is the latest version that's verified which is two weeks back and this is a version which I'm using 1.7 0.0 and if you want to see the commits of it so there's so many comments for this particular tag and you can also see the you can also this see the numbers so how will I how will I get this source code so if I go back to vs code and we have seen that right so if you want this source code of course this will be a bulky project so if I click here you can see this is where local this is where you can get the thing you can also download this Z but we don't want to do that what I can do is I can use https or SSH and of course I will not be pushing any code so https works for me I will just copy this and go back to in fact I will not do that in vs code let me use a normal terminal so I will go back to terminal here and I will say let's go back to the folder okay let me see where I am so I'm into my home folder let me just clear the screen and this is where I will say git clone I will mention that particular URL the moment you say enter it will download the entire vs code repository in your machine so it will take some time so basically the entire project which we have here we are getting that in this machine so vitamin is downloading let me see if I can find something interesting here so the entire vs code is built using typescript two percent JavaScript this is also last elements here and CSS HTML and others and you can see the number of contributors more than 1800 contributors that's great and then there's also branches here which we'll see later but if you expand this you can see there are so many branches here created important is the main branch which is the most important Branch here okay done so you can see I got the vs code and what I will do is I will open that vs code in my vs code okay this is inception right opening up source code in the vs code so let me go to vs code and open that folder so I will say open folder and in Naveen we got vs code open and voila this is the entire vs code source code right this is the entire code in fact you can also verify with the readme this is the readme which we had there right okay now what I want to see I want to get some information about it so what I will do is I will say terminal and I want to know some things from this so basically I want to see the log first so when I say git log and look at the all the commits which happened here so you will see their name who has committed it and what is the email ID you can see the time when it is committed and if you Center you will see all the list right we got the entire list and it's it's it will be huge now if you want to come out of this just type Q and you are out okay and now what if you want to see all the tags I can say git tag because now we know the commands right and this are the tags so they started with zero point 10.1 and if you go down the latest one is 1.79.2 let's see so if you go down okay still searching so these are all the versions of vs code okay so you can see uh 1.9.1 is the last release or they have the tags I'm not sure if they have publicly released it but they have the tags and this is a version which I'm using and maybe I want to know more about my version which I'm using so what I can do is I can say get show 1.79.0 that that's the version I'm using so you can see this particular tag got a commit from this particular author and on this day oh great and I can also see what's what they have done by exploring this commit this particular commit okay you can see I got the commit number now so this was I was looking for it right so I don't know why I was not able to find that but yeah it's here in fact when you say git log you can see there are a lot of blogs here right now if you want to print only one I mean the commit number and just some information there's one more way you can say git log pretty equal to one line so what will happen is by comma by entering this command which is git log pretty one line you will see the commits and the the message there and this is how you message right so you will also get an example by looking at other people's commit how they message something so you can see we also have some Number issue number and upgrade numbers so it was always helpful to look at other people's comments or messages so that you will know how you should be writing your messages now what if you want to make some changes let's say if I go back to any of the file this is the first time I'm downloading the vs code on on this machine or or exploring the vs code source code I can just go get into source code and vs let's say code there is some node code here okay so let's say in this particular file if I want to make some changes I'm not sure will it work if I make a change but if I make some change let's say uh this is anything where I can type any message here an existing message or let's say I just want to say hey uh on Windows let's say I give a colon and maybe I have done a very big upgrade to this particular project now how will I push it of course you have to commit in your local machine first so what you will do is you say if you say get status and you can see that I have changed one file this is a file we have which we have changed a cli.ts and if you want to you have to add it first you have to say CLI dot TS okay so first of all you have to get the path right you have to go to that particular path and then you have to say commit so if I say get status again this is the path which you have to go for so I will just copy this it's a git add enter so that's the path done and now I can simply say commit so git commit hyphen M and I will say major update and also enter and then the commit is done but that's only in my local machine okay and now if I want to push this to the server let's try what happens even if something goes wrong we'll see later how do we solve it now first of all I want to know the remote right because how will I push so remote is origin so I will say get push origin main I'm just trying to push in the main enter and it will ask you for the username password the reason it is asking me to sign in is because we have used https right and if you want to you if you don't want to mention username password basically we have to use the SSH now even if you are logged in it will not allow in fact let me just try that once again I don't know why I have canceled it okay so it's authenticating and done so you can see I'm logged in but it says permission to Microsoft vs code get denied to this particular username so I'm not allowed to do that right I can basically Fork this project or maybe I can just create a branch even that is not allowed let's try if I can create a branch here you can see you cannot create your own branch right so you're not allowed to do that so you have to be a part of a contributor here so once you're a contributor then you can do that right that's how you basically work with the projects okay so we have done enough talk on this uh we'll try to see how do you push in your own project in fact we have seen that uh in the upcoming videos we also work on branches which will be quite fun so yeah that's it from this video that we have seen how do you download a source code and do some experiment with it we'll talk about the git Branch now this is a very awesome concept which is there in git and this is what makes git one of the best version control system now what exactly branching are how do we use it how do you merge two branches and what will what make goes wrong when you merge two branches we'll try to understand that in the next few videos so let's try to understand what is branching first and for that we need to get back to our project now this is what we were doing right on vs code uh we were able to get the source code from the GitHub but then we don't want to work with this of course because even if you can do some changes I will not be able to push on the remote repository so let me go back to our repository so I will say open recent git goes now this is a project which we are working right and if You observe you only have two files here nothing fancy just two files and we got readme.md we got user service text okay make sense and then uh the first thing you have to do is you have to always check get status if everything is committed uh you don't have anything in the unstage OR modified stage so you can see we have git status everything is clean so we can go forward now if you go back to your GitHub and if you see we are into git course now so basically if you see there are different things on the screen one thing interesting is we have one branch now what exactly this Branch means see the thing is whatever you do okay whatever work you're doing and you're pushing from your client side to server side or your remote repository you have a branch and it this is going into the main branch now this is the name of the branch which is Main and by default when you create a project of course uh you you do get either Master Branch or main branch based on which version you're using and which tool you're using so you have to check this what is your branch name first of all so for me it is Main and you might have some other Branch that's completely fine and there is no rule in the world that you should have only this Branch name or that Branch name you can go with any branch name that's your choice but commonly we use main nowadays and you can see we have one branch that also means we can create more branches right so whatever by default you're doing that goes into the main branch right and if you remember when we were pushing the code from the git client or The Terminal to This Server we were using main as a branch so we used to say git push origin main right but what if everything is working so let's say you have a project everything is working and now you want to do some experiment now one of the thing you can do is you can of course you can do experimentary let's say I'm happy with my code which is working fine and then I want to do some experimental code in this user service maybe I want to create an avatar for a user for user and all these are experimented okay I'm not sure how will I do it so I'm just trying to add this feature and now let's say this is a very bulky code and this is not the only file you're changing maybe of changing multiple files and you thought it would work and now it's not working okay and then the release which you did to the users the earlier version it has some bugs okay and how will you solve that bugs now because the moment you make changes and when you push this to the server of this when you push this to the GitHub repository how will you come back because you have updated your main see one thing you can do you can uh you can go back with the comments you can you know we can actually time travel between the commits so you can go back to the previous commit but again why to do all those things what you can do is whatever experimental feature which you are working on or maybe your colleagues are working on so you can work on a different branch now this will not affect your main branch okay example something like this you can just click here and you can have an option here of creating a new Branch you can simply type let's say a feature one now this is a new branch which I'm creating here okay so you can do it from here on the GitHub or which is the best way we can do it from the command line right so let's go back here and let me create a brand so what I will do is whatever changes I want to make I will not do that in the main branch I will do that on a separate Branch now first of all we have to create a branch so how do you create a branch it's very simple you simply say get uh there are two options basically for branching one is checkout now this is the older one and most of them are familiar and used to check out the new feature or new the the new command which we got is switch I think this came in 2.23 a version so it both are okay if you want to use checkout if you want to switch that's your choice now for me I feel switch looks much better then check out because sometimes you get confused with all these words right when do we use pull when do we use fetch when do we use checkout so switch actually makes sense when you want to switch between two different branches right so but then let's go with the older one which a lot of people are familiar with so you can simply say check out and you can mention the branch name so the branch name is feature one now this branch is actually not created okay so we don't have this Branch yet and if you type this command and if you say enter you can say it will say the feature one did not match any files known to git so basically we don't have a particular Branch name feature one so we need to create one so for the first time you have to create a branch right once the branch is created you can switch using with using git checkout feature one so what I will do is I will just type this command once again get checkout now since we we are doing this for the first time if you want to create a branch you have to say hyphen b or you can also say hyphen offer Branch both works and the moment you do that it will create a new Branch okay so now the branch name is feature a feature one and it also says you know switched to a new Branch feature one so basically now you have two branches you've got a main branch and you've got a feature one branch how do you know how many branches you have so what you can do is you can say git branch and you can see now we have two Branch we have feature one branch and we have a main branch now the question is which branch is active and that's where you will see this star okay so star means you are I mean this is basically a pointer which means currently you are on feature one one feature one branch and you can see it's also in green color now whatever changes you make will be happening in feature one let me show you let's say I will do some changes here okay so I'm adding new feature because this experimental Branch right so I will say create an avatar for user okay I will say save and imagine this is a lending code I'm just typing one line but uh yeah it can tell in the code so once I do that what I can do is of course I can say git status and you can say in git status it says on Branch feature okay it's not saved okay my bad I was expecting some on stage and then it was saying something okay now it is you can see I failed to save it and now I have saved it so it says modified now once it is modified you have to say add and you have to mention the file name and then you have to say get you have to commit this right so you have to say git commit hyphen M and you can send the message you can say uh experimenting with user of the r okay so basically we are doing experiment with the user author that's what I'm saying here and I will say enter now this is committed okay now question arise in which branch it is committed it is committed in the feature one branch okay main branch has no idea what you're doing with feature one branch so you can imagine this is your main so this was your last comment right before doing the branching this was your last comment and may may knows about this commit now what we did is we have updated some feature in a feature Branch main has no idea that's a new commit and only feature knows it feature one branch knows it okay so this looks cool right now if I say git log so you can see it will give you all the comments this is a recent one you can see this is a recent one it says experimenting with user I'll just try to remember this now what I will do is I will just go back to the main branch and look at the code as well so this is my working area right look at this code so the user service has one more line here right but if I move to Main Branch how do I switch how do I switch between these two so you can say git Branch or the gate switch so either you can use checkout or you can use switch I'm using switch now you can also use checkout that also works I'm switching to main the moment I do that look at the changes that line actually went it's because main has no idea about that new line but if I go back to feature once again you got the new line so this is a beauty between when you work with different branches right uh in fact if you have more files in the feature one it will also show those more files and when you go back to main again it will come back so that's how basically you create a branch and you work on it of course you can create multiple branches there is no limit but what is the use of creating a new Branch right of course if you can do something you can do it on Main Branch and if you are doing something new on the feature one branch how will you get that data in the main plans again that's a question we still need to answer but we'll do that in the upcoming video now in this video let's try to create some more branches so that we can also see how do you delete a branch and also what's a shortcut to switch between branches so let's try this first one let me create some more Branch here so I will say get how do I create more branches I can simply say switch of course you can use checkout or you can use switch that's your choice if you are using a checkout you have to use hyphen B option and if you're using switch you have to use something called hyphen C now you can say hyphen C or you can say hyphen iPhone click create that's the option and then you can mention the branch name let's say I'm creating a feature two Branch okay so I'm creating one more Branch now so in total how many Brands we have we got three branches how to identify so either you can say git Branch now this will give you the list so there is one option another option is hyphen iPhone all again both does the same thing but the difference is in this get Branch you will see the local branches in git Branch all you will see the local branches as well as the remote branch and if you can observe in the remote we only have one branch at this point if you go back to your GitHub we only got one branch okay we don't have this feature Branch yet so we only got one you have one branch but you will see how do you push a branch to the GitHub now at this point we can see we have only three branches so we can check those things with the help of git Branch or if you want to see the remote as well you can say git blanch all now let's say again if I say git Branch we are into feature two right now what if you want to move back to the last branch now since we say switch it has created New Branch but let's say if I want to go back to the previous Branch I can simply say git switch hyphen the moment you do that now you can say it is switching back to feature one because we came to feature 2 from feature one okay so if you want to do that shortcut of going back to the previous Branch you can say hyphen that will be making it easy now once we have seen this let's also talk about deleting the branch so you can say get branch and you have to use hyphen D so if you want to delete a branch you have to say hyphen D or you can say hyphen hyphen delete that's an option and then mention the branch name which is feature two let's I don't want to work on feature two so you can simply say feature two and then done so you can see it has deleted the branch and now if you check the branches you've got on it too we got feature one and we got main so now let's try to push the branch which is there in the local repository to the GitHub remote repository so you can see we have a feature one branch but if you go to GitHub you don't have it there so even if I refresh so you can see in total we got one branch so let's create one so what I will do is I will go back to my vs code and this is where uh okay even before pushing it I just want to make few changes so that it will look good so what I will do is first of all I have to check which branch I'm into I'm into feature one branch and in feature one let me create one more file which is for the admin so let's say this is admin service Dot txt and what admin can do is add and remove users change the rules okay something like this okay so again I assume I'm just writing one line of code but behind the scene there are multiple lines of code so that it will look good okay so now what we're going to do is first of all we are into feature branch and in feature Branch if you say git status there is one file which is untracked so we need to basically add this file which is the admin service now once you have added it it's time to commit so I will say adding admin service okay so basically we have added one more service now and if I say get status everything looks good but if you see now we are into main branch right so if I see the branch so if we want to feature one branch and now if I switch to the main branch just look so the moment I say enter see what will happen to the files the moment I say enter you can see there is one file which I have been removed now because the main branch has no idea about this file and that's why you can see there is also cross here but in main we only have two files the moment I go back to the feature Branch now feature one and if I say enter and now you can see we got three files so this is this is how basically you when you work you can actually work on those files okay cool but then I also want to push this to the GitHub remote repository right how do we do that it's very simple now so you can say get push origin because that's the original we have and now we have to mention not main because in the earlier case we used to say main right but this time we are pushing a different branch which is feature one and when I say enter now it is pushing this particular local repository to the GitHub repository and it's done you can see there's no problem it says on my remote repository which is github.com 112020 git course dot get it has a new branch called feature let's verify let's go back here and you can see it still says one branch but you can see there's a notification here feature one had a recent push less than a minute ago okay let me refresh to see uh two branches here and you can see now we have two branches this is the main branch but if you switch to the feature one branch you can see you have three files okay so this is the beauty of uh using branches right so you can also see that on the server okay that's how basically you push the branch on the GitHub repository so how exactly things are working here so what happens when you create a new branch is it really copying the entire project and doing it so let's try to understand that in the next video where we understand how branching basically works so let's understand what happens when you create a branch so let's say you have just done the git initialization on the working directory now at this point what happens is you get a different area inside your working directory which is called your git right dot get folder now basically whenever you do your comments of course you have to do these commits in some Branch right and by default when you say get init it creates a master Branch so let's say in our workplace we are carrying a main branch right so default for us is Main Branch right now every time you basically do the commit so let's say when you when you do the first commit what git does is it creates something called a snapshot so it will take a snapshot of your files right and then it will give it it's a commit number that's your check sum basically uh we have seen the exact code values right so that's your checksum and then there is one more thing called pointer now how the pointer looks like let me show you so if you say git log and when you say enter remember this we have seen this thing before there's something called head so at this point it is showing me a feature because we are into feature Branch what I will do is let me just switch to also get switch Main and now if I do the same command again you can see it says head is towards main let's say we don't have a feature Branch at this point we only have main branch and then the header so that's your main pointer so it is pointing to the main branch right and Main is basically pointing to your uh to your commit now this is a recent commit is this one right now let's say next time you are doing one more commit in the same branch of course so what it will do is it will take a snapshot now in this snapshot basically you will have those files which have been changed okay so it will not simply copy every file it will copy those files which have been changed now you have a previous commit you have a recent commit with the new changes and then it will also have the parent commit why because if the files which have not changed is there in the previous commit right so basically it will have a pointer as well so we will see that later how the parent look like so we it create a parent so it also has a parent it has a checksum uh and multiple things it also save data in a tree format but just to keep it simple let's say we have checksum and the commit ID or the comment hash so the main is pointing to the new commit the hedges point to the new commit and now we are doing one more commit so what will happen is with the new commit you will have a bin pointing to the new commit and had a point to a new commit ah yes at any given point if you want to go back to the previous previous commit what you simply do is you your pointer will move from the latest Branch to the previous comment whatever you mentioned or let us commit to previous commit is that simple right now what happens is at this point when you create a branch what is happening now basically you have a main commit right the main branch the moment you create a new Branch both the main branch and the new branch which is feature and feature one in this case is pointing to the same commit now let's say you decided to upgrade your features in the feature one branch at this point it will create a new commit and your feature one is pointing to the new commit right what about the main many Stills with the old commit right so that's how basically you create two different branches and you can work them you can work on them individually if you want you can also made you can also work on Main maybe you want to do some more commits there because maybe uh after the main commit uh you got you found some bugs of course you are working on feature Branch but let's say you you found some bugs in the main now of course you will not directly work on feature one you will what you will do is you will create a new commit from the main so the main will be pointing to the new commit now and the feature is coming is pointing to the other commit so that's how basically it creates the branch now if you want to visualize this uh of course you can do git log it will give you all the logs right but there is one more command you can say get let me just clear the screen so there's something called get law blog and you can draw a graph here now to this point we have not done the emerging that's why it is only showing to the main one so it says what are the commits what was the message which you have done uh so the comment and the message and the commit and the message if you say enter you will see more now if you want more visual representation what you can do is you can install one extension which is called git graph in vs code and okay it's it failed to fetch okay so you can see there is something called get graph here this is the logo if you want to download and when you say install so it will take some time to install I think it's done and if you want to use it you have to go to this particular icon here which is for the get or Source control and there is an option here so if you can see this is a button which have to click and now you can actually visualize everything so if you click on this this these are the things which happen with this particular commit and this is what I was talking about the parent for this video comment this is a parent right this was the previous commit so if I want to show you in the console as well we are into feature right we should focus on the mean not feature because in this we are into main so I will just click here so yeah this is the commit right the recent commit and that's what we have here and for this commit the parent is some is one commit before that so you can see it says patent now of course for one particular comment you can have multiple patterns we'll see that later but at this point you can see we have only one and that's why to say there's a plural form right which is balance and that's how basically you can see the things here so yeah explore this and we'll try to understand this more so you can see at this point we have created a new branch which is a feature Branch now everything else is happening on the new Branch so yeah that's how Branch basically works and now we also want to understand how do you merge two branches that will say in the next video so basically now we have two branches right so if you want to see them again what we can do is I can just clear the screen and I can say get branch and you can see we have two branches right and now what we want is we want to basically merge these two branches we want to merge Main and we feature one so of course we have done the work on feature one it looks good I just want to merge it to the main branch how will I do it uh so the first thing is first of all let's explore the files I am into my main ah right and if I go back to get so just just check what are the difference we have here so if I say git switch to feature one and you can see uh there is extra file here which is admin service I just want to check if everything is good it's clean I like I also want to verify if do if we have admin service on the GitHub so if I go there if I refresh so yes we also have admin service here so that looks cool right so now what I will do is I want to merge the data or the features in feature Branch to the main branch how will I do it how do we merge so to do that uh what we need to do is we need to use a very simple command called merge basically there are two ways of doing it one is merge which we are doing now and the second one is rebase we'll see later what rebase is but at this point let's focus on merge we are saying git merge and then we just have to mention the branch name but to do that we have to make sure that we are in the main branch so if you see if you check which branch we are into behind the feature Branch so we need to move so we'll say switch to the main branch and now we can do git merge so we just have to say git merge and the branch name which is feature one and when you say enter okay it worked the merge is complete there is no problem sometimes you do get problem we call them as merge conflicts we'll try to create merge conflicts later and we'll also see how do we resolve it but at this point there's no issue and you can see we got git merge and it's working how do I modify this if you go back to your main branch of course we are into main branch and in main branch you can see we have admin service okay that looks cool I just want to see if git status and everything looks good because the commits which happened in feature one also came into the main okay the way the way you can verify is by doing a log and you can see we were basically done this thing in the feature but now it came into Main and we can also verify that with the git graph and if you see here that's why we have done the merging right so now it came into Main Branch from the feature Branch this is what it says okay so merging is complete now if you go back to your GitHub and if you see here in feature when we have three files but if you look at your main branch we only got two files because the update is not happened on the server okay there's one thing which I missed normally whenever you do this merging and pushing on the remote repository of course you have to push right the first thing you do is you pull your remote repository we have not done that because it was safe for me because I'm not doing any we don't have any collaborators I'm not working on Main separately but that's a good idea always try to pull first okay because when you say pull so from the remote repository you will get the updated code on your machine before merging okay so how do you pull basically if you want to do that it's very simple let me just clear this screen so you have to say get pull the same way you do push so it is a get pull origin and you have to mention the branch which you want to pull which is Main in this case right this is the step which you we should have done before merging okay but anyway we have done the merge and now it's time for us to push it to the remote remote repository so it's a git push origin and we have to push main let's do that uh things are looking good there's no problem and done you can see the pushing is done let's go back here and when you say refresh now in the main you can see we have three three files so this is updated and we are good okay so that's how basically you merge
Info
Channel: Telusko
Views: 197,661
Rating: undefined out of 5
Keywords: telusko, navin, reddy, tutorial, Java, Blockchain
Id: vwj89i2FmG0
Channel Id: undefined
Length: 120min 37sec (7237 seconds)
Published: Mon Sep 04 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.