Part 4 | Git Tutorial | Git Commands | Compare Files using Git Diff Command

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone welcome you all in the today's  video we are going to discuss about git   diff command which is very very important command  in gate so now let us see what is the use of get   div command so in version control systems we have  a different stages like we have working directory   and after that we have a staging area and after  that we have a local repository or we can say   local repo and then we have a remote repository  right so then we have a remote repository   so this is a structure we will follow in the  version control system so whatever files which   we are currently working so those files by  default available in the working directory   and before committing those files into local  repository we have to add them to the staging area   and from there we can commit them into local  repository and finally we can push them into   remote repository so this is the exact  process now the files will be available   in any of the stages like some files will  be there in the working directory some files   will be there in the staging and files will be  there in the local repo or remote repositories   so how we can find the differences like suppose i  have a one file which is uh added in the staging   area now i want to compare the file which is  available in the working directory or i want   to compare the file content which is available  inside the working directory and the staging area   similarly i want to compare the file  content between the working directory and   local repository and i want to compare the file  content between the working directory and remote   repository or similarly i want to compare the file  content between the staging and local repositories   how we can do that so to compare the file contents  between working directory or staging or between   working directory or local repository or between  local repository remote repository we can use   git div command so get diff command basically  used for comparing the files in version control   system right so compare the files in the version  control system so now we'll see how we can use   this command practically so for that first of all  we need to have working directory which contains   a file which contains some content and then we'll  create a staging and local repository so we will   talk about remote repositories separately  later so for now let us focus only on three   working directory staging and local repository  okay so as a first step what i will do is i'll   just have two environments let us say this is my  working directory this is my staging area and this   is my local repository so first let me just create  a new project in which i will create a simple file   so let's go to c drive and here i will create a  new folder so i'll name it as a sample project   and open this project so inside this i'm  just opening my git bash so this is my git   bash so here i can execute all the commands so  by default i don't have any files in my project   so i'll try to create a new file in my project  then i will also add version control system to   this particular project so for that we have  to create a local repository we have to use   git init command so let us do that let me just uh  put these two windows side by side [Music] so this   is a a project workspace location currently  i don't have any files in my sample project   and this is my a git bash okay so now let us uh  currently we are in our project itself workspace   location itself so what i will do is i will create  a new file in my project so how to create a new   file through command prompt if i want to create we  can use linux command so we can use like a bim is   a command and i'll create one simple file called  index dot index dot txt all right so once you've   created this file uh when i enter which will  open the command prompt so which will open editor   so in this we have to add some data so how we can  add i'm just trying to add the data into the file   so here i'll just type something called animal  okay i'll say animals and after that i'm saving   the file so now index.txt which is created in my  sample project location currently which is there   in your workspace now let us update this so this  is my file you can just consider this is my file   so inside this file i added some data so let me  just add some data okay just a second so here   we can just remove this okay so now let me  just add file into workspace location just   i'm adding some shape here and click on  edit text and here i have added animals   okay so this is a current one single line which  we have in this file inside the working directory   fine so after that what you will do is now  currently we have created just a one file and   which contains only one single line so now let us  try to uh create a local repository so currently   we don't have version control system for this  project so let us create a new repository so how   to create a new repository by using git command  git init get init so which will create a new   empty repository so now it is created initialized  empty get repository for this particular project   okay so once it is created then what i will  do is i will try to add this file into staging   area so how we can add so i want to add this file  to staging area so how we can add by using add   command so i'm writing get add and we can specify  the file index.txt or you can say simple dot   and which will add all the files to your staging  area so currently we have only one file in the   project so this command will add that particular  file into your local repository okay so now if   i just look at the status get the status so now  we can see this is a new file which is added to   your local uh add it to your staging so now what  i have done this particular file we have added   to the staging area now currently it is there in  the staging area and also in the working directory   the same content which we have the same content  which we have now so after adding this file into   staging area now what i will do is i will update  this particular file so additionally i will try to   add some other thing like i say birds okay so let  us try to add this one so now what i will do is   let's go back to the github and then again i'll  try to update the file i'll say vim index dot   txt open the file one second so previously we  have animals right i want to add some information   or some other content into the same file so  i'll say insert and here i'll add one more   line and then save the file okay so once we  have done this what we have done so we have   added already file to staging and after adding to  the staging i have done some modification in the   working directory okay i have done some  modification in the working directory   now these changes are not part of your staging  area okay so now this is the environment setup so   now if i just look at the status gate status and  now we can see this is a file which is modified   in the work space which is saying in the red  color right red color text which is modified   but this is not part of your staging area so  in the staging area in this file we have only   one single line but in the working directory we  have it two lines in the file okay so now what   is my first requirement is let's go back to the  nodes so my first requirement is i want to see   so i say requirement1 so my i want to see the  difference in a file content between the working   directory and the staging area so i want to see  the difference in file difference in file content   between working directory and staging area so  currently if i just look at here so this is   our working directory which contains a file which  contains the two lines and in the staging also we   have file which contains only single line now  i want to see the difference between the file   content in working directory and staging area so  how we can do that so this is my first requirement   so to do this we have to use uh div command okay  so what is the command we have to use it here   is we can say get get diff and then name of the  file so git diff and name of the file so git diff   and the name of the file so when i execute this  command which will show you the difference between   the file which is available in the staging  area and also working directory now let us   try to execute this command through uh git command  prompt and we'll see the difference so let me just   clear it now i'm executing this command i say get  and i say diff git diff then file name index.txt   so once you executed this command now we  got some number of lines so let us try to   understand this text what it exactly displayed  so that we can just ignore this warning and uh   okay this is also we can just ignore and this is  a one we have to understand what exactly it is   so let us copy here and let us try to understand  what exactly it is so basically here uh the first   d phi fun iphone git is a statement or the syntax  which is given by git now what exactly the rest of   the things means so a slash index dot ext b index  dot txt so what exactly it means so here a and b   okay a and b is representing source and the  destinations okay so a dot index dot txt   which is representing the source and the b slash  index dot ext which is representing the source   okay so here we have something called a working  directory and staging area so which one is the   source which one is the destination so normally we  consider working directory as a source staging is   a destination but in the gate we'll take a reverse  way so staging here this is a source location this   is a target location or destination location so  staging is a source and working directory is a   target as per the get so here a slash index dot  txt which is actually represents source which is   representing the source so let me write the nodes  here which is representing the source that means a   staging area file so this file is representing the  staging area file and this one is representing the   destination file which is representing the  destination file representing destination   file means what here staging is a not staging  workspace is a working directory or workspace is   a destination directory okay so these two now let  us go to the next line so here there are three   things are shown here what are exactly these  three things the first part right so this one   is representing the hash of the file content so  normally the file content will be stored in the   form of hash or hashing algorithm internally  git will use it so this is representing the   hash of the file content okay the first one so  this is representing the hash of the file content   from the source or staging okay the first one  so this is representing the the first code is   representing the hash of the file content which  file contained from the source or staging from   the source or staging now the second one so  this is representing this code is representing   hash of the file content from the destination  or workspace so this is representing   hash of the file content from destination or  workspace okay so these are the two things now the   last value so what exactly this is representing  so this is exactly representing the file   mode so we can call it as a git file mode so  git file mode again contains the two parts   get to file mode contains a two parts the first  three digits are representing the type of the file   what type of the file it is so this is represents  represents type of the file type of the file   now the last two type of the file means it can be  any type like a which can either normally we have   created text file right it's asking text file  similarly whatever type of the file you created   it will show you the type of the file so the first  three digits are representing the type of the file   and the next three digits the next three  digits or representing the file permissions   file permissions will be representing so what  exactly the meaning of 6 4 so as we said before   git follow all the linux commands right so six  four four is representing the file permissions   so basically what is the meaning of six four four  so six means read and write and 4 means only right   and again 4 means only write so in the line x  we have special type of permission like 4 is   representing the reading mode read permission  and 2 representing the writing permission one   representing the execute permission and at the  same time we have a three types of users in linux   group owners and users so here the first six  means what four plus two four plus two so   that means a write read and write permission so  read and white permission we have for the groups   owners and write permissions are representing  the four four representing the read permission   and again r so for the groups and  others have only read permission   and owner is having read and write permission so  644 is representing the file permissions in linux   the same thing is applicable for git also so  that is a meaning of this one so get file mode   now let us understand these two things what  is uh a slash index.xt plus plus plus b slash   index of dxt so this particular part  so this particular part is representing   is indicating source file missing some lines okay  or we can say source files missing some lines   source file means a slash index dot txt  minus minus minus this means representing   missing so source file is missing so we already  discussed right here a means a source file b is   a destination file here a slash index is a source  file b dot index is a working directory that is a   destination file so here minus minus minus means  missing so a slash index dot txt means which is   a source file in the staging area and it is  representing missing some lines missing some   lines so if i just look at here here the staging  area the file is animals so there is only one line   but in the working directive we have a two lines  that means there is one line which missing in the   staging that is your source so that's the meaning  of it now this one this is also represents   new lines added in the destination file so  some new lines so here we already discussed   the b slash index which is representing the  destination or working directory right so   plus plus means what the new lines are added in  the destination file which is walking directory   so after adding this file into the staging area  we already again added one more line called birds   which is not there in the staging area so that is  exactly representing this so in the destination   file which is a working directory some new  lines are added that is a representation of   plus plus plus so now this one so what exactly  this means so minus 1 plus 1 and 2 so minus one   and plus one means from the first line to  first line and the second line so in the uh   in the source sour means source means what so  source means what staging area we have only one   line missing minus one but in the target in the  destination that is in the working directory we   have one line and also we have a second line so  one two two lines we have in the working directory   but in the staging area one line is missing so  minus 1 which is representing that and now the   last two lines are most important so in the last  two lines sometimes we see one space here or you   can see plus or sometimes you can see minus also  so what does exactly mean so here space or plus   or minus so there is a meaning for that so what is  that meaning if any line prefixed with the space   means it is unchanged that means what so there is  a space here that means this particular line is   same or which is not changed in source and  destination that means in the staging area   and working directory and if i just look at  here this particular line the first line is not   changed in the working directory and the staging  area so it is exactly same so it is not changed   so space is representing the unchanged if any  line prefix with the space means it is unchanged   now you can see plus here so plus is representing  means it is added in destination copy   so if any line prefixed with the plus which  means it is added in destination copy what   is the destination here walking directory is a  destination so we have added one new line called   birds right so that is a representation of class  here so plus means which is something is added   this particular line is added in the destination  copy that is your working directory copy   okay sometimes you can also see minus which  means that is a line which is removed from the   destination copy okay so this is a meaning  of this particular result the output of git   diff command so now by seeing this output we can  understand what are the exact differences between   the working directory file and staging area  file so in this requirement we have seen so   what is the difference between the file content  between working directory and staging area so we   have seen these differences so similarly we can  also use git diff command to compare the files   between other other areas so let me just  talk about another requirement let us say   so requirement two so in this my requirement  is i want to see the differences i want to   see the difference in the file content  between working directory and last commit   working directory and last commit then how we can  see that so working directory and the last comment   so so far we have working directory and the file  is available in the staging but here we have   only one single line but uh we don't have anything  in the local repository so once you commit this   file then we will get the file contained in the  local repository so until unless we haven't have   any files in the local repository so now what i  will do is i will commit this particular file into   local repository okay so animals so this is only  one single line which we have in the staging so   i'll try to commit this file into local repository  and after that i will compare the file content   between working directory and local repository  okay so let us try to commit this file into   local repository so how to commit this file into  local repository so then we can go back to the get   and from the git bash i'll execute one command git  commit iphone em and here i'm writing comment is   my first commit this is my first commit and uh  file contains only one single line right so i'll   say file contains uh one line so this is my first  commit so as soon as you executed this command   what will happen so whatever file we have in the  staging area will move to this local repository   it is not mode actually it will send the one more  copy to the local repository so now we have a file   in the working directory which contains the  two lines and we have a file in the staging   area which contains only single line and the same  file we have committed to your local repository   and this is my first commit this is my first  commit so let me write the comment here   so we already done the first commit so first  commit so in the first commit file contains a   one single line okay so we have done the first  commit so after doing this now let us compare   the file content between working directory and  local repository so previously in the previous   requirement what you have done we have compared  file content between working directory and staging   so now we are going to con we are going  to compare between working directory   and local repository okay or committed file so  whatever the file which is committed which is a   recent commit or the latest commit we can say so  we can have multiple commits also so we'll see one   more example for multiple comments so as of now i  have done only one commit so this we consider as   a one latest commit our most recent commit we  can say and we will compare working directory   file contained with a most recent commit file okay  let us compare this that is our requirement so to   see the difference in file content between working  directory and the last commit or the latest commit   now how we can execute this command so we already  committed this right we already committed so   after committed what i will do is so currently we  have only one single line in the local repository   uh in the working directory we have uh two lines  so basically we are comparing the content between   the working directory and one last commit  right so what i will do is uh the local   repository file contains only one single line and  working directly currently have only two lines   okay so now i'll try to add one more line in the  working directory i will try to add one more line   in the working directory so let us try to  add so currently animals and birds we have   so let us go to the git prompt so i am trying to  add one more line in the working directory and   after that i will compare this working directly  with the local repository so let us clear it   so how we can add again vim command  index.txt i'm opening the file   and currently we have only two lines so now  i'm going to add one more line so insert and   i'll say fishes okay and then i'm saving the file  all right so now i have added one more line in the   working directory that is officious okay now  this is our file so now this is a file which   is a file content which is available in the  working directory now in the local repository   so still we have animals is the first commit then  we have to compare these two we have to compare   working directory with the local repository what  is the difference in file content so let us try to   execute the command so what is the  command which we have to execute   so here the last commit whatever we have done the  last commit which is always uh referred by head   head keyword so whichever the suppose we  have multiple commands also will be there   but whatever the new commit the latest or the  last committer which is always representing   with head okay so just you have to remember  this so the last commit is always referred   using head the keyword okay the last commit so  whenever you see head that is representing the   last commit in the local repository so now how  we can write the commit how we can execute the   command to compare the files in the working  directory and local repository so for that   so we have to write one command like  this i say git git is a command git   and diff so head head is representing the the  last committer and name of the file index.txt so   this is the commander so what exactly this command  will do is which will find the difference between   the content of two files the first file is  present in the repository the latest commit head   is representing the latest commit or last commit  index.txt which is a file we are comparing with   so this is a command which you have to execute now  let us execute and see what is an output we will   get so go to the github uh go to the git bar cell  and help execute one command get diff and head   index dot txt okay so as soon as we enter this  now this is an output we capture so let us try   to understand this output by seeing the stages  so here we can see the stages so what is an   output here so we are compared local repository  last commit with our working directory right   so let us try to understand this so these are the  three important lines which we need to understand   so rest of the things will show you like a hash of  the source file hash of the destination file and   type file mode and everything so let us understand  these three lines so here animals before these   animals there is a space means what this is  unchanged space is representing unchanged so in   the both animals is there which is unchanged now  birds and fishes for both of them there is a plus   so what does that mean so here plus is  representing the destination file what   is the destination file here walking directory  so that means birds and fishes these are the two   additional lines which we have in our working  directory file so which are not there in the   latest commit file latest committed file so that  is a representation of this text so like this we   can execute this command and we can compare the  file content between your working directory file   content and your the last commit file content in  the local repository so this is one requirement   now i'll show you one more requirement so  let us see one more requirement so i have   let's say requirement three so in the requirement  three what i want to do is i want to see the   difference in file content between staged copy and  last commit staged copy and last committer so what   does that mean staged copy means what this is a  staged copy staging and last commit means what   there is only one commit we have so far we have  done so this is a committed file so now we need to   compare these two so previously we have compared  we have compared working directory and staging   and also we have compared working directory and  a local repository so now we have to compare   now we have to compare stage copy with  local command so these two files we have   to compare staging and local repository so  how we can compare this so as we know the   latest commit or the last commit is represented  by a reference by head referenced by head but   how we can represent the stage so to represent  the stage we have to use one more option called   iphone iphone staged so before that what i will  do is so currently there is no difference in this   right so whatever the file we have in the staging  the same file we have committed in the local   repository in the last commit so content is same  so now what i will do is i will add this content   the working directory contained to the staging  area so then we can see the difference between   staging and local repository right so let us try  to add this working directory of file content   to the staging area so currently we have  only one line in the staging area file   so we need to add these two lines also so to do  this what i will do is i will add them so get add   data so when you execute this command what  happens now whatever the rest of the lines   we newly added in the working directory  will be added to your staging area so now   in the staging area as soon as we added now in the  staging area another two lines also added birds   and fishes okay so now whatever content we have  in the working directory the same file content   which is there in the staging area so now as part  of third requirement we will compare these two   staging and local repository in the  staging file we have a three lines   in the local repository in the last commit we have  only one line so let us try to compare these two   so the command is here the command is get diff  and so we have to compare our last commit with   your staging file so for that what you have to  do we have to use one option called iphone iphone   staged stage and head is representing always last  commit it is always representing the last commit   so this is a command which you have to use and  file name index dot txt so this is the command   which we have to use or you can also use another  command the same command you can use like this get   diff instead of iphone iphone staged so you can  also say catch so there is one more option called   catch okay so these option also we can use but  most of the times we use only staged so let me   just remove this so let us try to execute this  command so what this command will do this will   compare the file content between staged copy and  the last commit in the repository so let us try   to execute this command now let me clear this  and i say get diff iphone iphone staged head   is representing the last commit in the repository  staged is representing staging area and on which   file you want to compare that file name we have to  specify index.txt and if i don't specify the file   name what will happen which will compare all the  files multiple files if you have multiple files   in the staging and the local repository which  will compare multiple files and it will show   you the results so currently we stick to one  file index.txt now let us execute this command   so now it shows some difference so let us try to  understand this output based upon our analogy so   here as soon as uh we have staging staging  file we have a three lines right so in the   local repository or in the last commit we have  only one single line right so now let us try to   analyze this output which is correct or not so if  i just compare these three lines the first animals   there is a space that means this is unchanged  so animals is there in the staging file and also   local repository file in the last committed  file so plus burst plus feature so these two   uh additional lines which are there in the  destination file so what is the destination   file here staging is a destination file staging is  a destination file so birds and fishes these two   new lines which are added into the staging  file but we are not those lines are not   there in the first commit so by seeing this  we can understand the difference okay by   understanding the difference okay and if i just  look at the numbers also so here there is only   uh minus one this is representing the source  which is a local repository and plus one and three   so that means there are three lines which are  available in the staging files so from one comma   two means from one to three lines which are there  in the staging area but in the local repository we   have only one line that is a representation okay  so by seeing this output we can easily find the   difference between the files between staging area  and last committed file in the local repository   so this is a analogy now so let me show you one  more requirement so for example so for example   uh i want to compare there is one more requirement  let's say requirement for so i want to see   okay i want to see the difference in file content  between specific commit and working directory copy   specific commit and working directory copy so  what i'm saying is here we have only one commit   and suppose we have multiple commits so i want to  compare my working directory copy or this content   with specific commit so specific commit means what  in the first commit we have added one line in the   second commit we may add more lines like that  so you may have n number of commits but i want   to compare this current working directory file  content with the specific committed file okay   so then how we can do that so what i will do is  before comparing this content with the specific   file commit so for the last committed we have  used head right head is representing the last   commit let us say have committed three times first  time second time and third time so third time   whatever i committed that's the last committee  we can call it as a last commit okay so this is   the first commit i have done so let us do one  more commit okay and for that what i will do is   so whatever the three lines which we have in the  staging i will also update these three lines in   the local repository so i can commit one more  time okay i'll commit this one so how we can   commit these three lines in the local repository  so for that i'm trying to use commit command   commit iphone em and in the double quotations uh  this is my second comment right so i'll say second   commit second commit and now this file contains  the three lines right so the file contains a   three lines so this is my comment i have created  so second commit file contains the three lines so   previously we have only one line first commit we  have only one line now i'm doing second commit in   the second commit i will have a three lines in  the repository so let us execute this command okay so yeah git is forgot so let me just add  git also get commit iphone name all right so   once it is done so once it is done now what  happens these two lines also added into local   repository file so now this is a second commit  so this is the second commit in the second commit   we got three lines in the first commit only  we have one line so this is my second commit   file contains how many lines three lines  so file contains a three lines so now   let us compare so what do we have to compare so  to see the difference in file content between the   specific commit and working directory copy  specific commit and working directory copy   so here working directory means this one so i have  a three lines so i have a two comments here which   one is the last commit whichever commit we have  just done that is the last comment so this is   representing by head this is a representing  by head but i want to compare with the   previous committer that means a specific  committer okay so working copy i want to   compare this file content with the previous commit  or a specific commit which we know but how we can   compare that how we will know which commit it is  because there will be so many commits are there   so we can do this by using commit id so first of  all we need to have commit id okay so currently   both the copies are same so for that what i will  do is i will also add some additional content   in the working directory so in the working  directory let us add one more line like i   will try to add trees okay now we can see some  difference so let me just add through git also   so get how we can add them you can open  the file that is index.txt and currently   we have a three lines so now i'm trying to  add one more line called trees okay and then   save the file so once we have done this we  have four lines in the working directory file   and in the remote repository we have a three  lines so these three lines committed file is   second commit the last commit but in the first  commit how many lines we have only one single line   okay so this is a second committed  file actually if i just look at this   this is a second committed file so in the second  committed file we have a three lines but in the   first committed file we have only one single file  we have only one single file one oh sorry we have   only one single line in the file in the first  commit so now which one is the last commit here   which one is the latest commit so this one is the  second command is the latest committer so now i   want to compare the working directory file content  with the specific commit whichever commit you want   to take you can commit so i want to take the first  commit now so there will be some difference so how   we can write the command here so to write the  command what you will do is before that we need   to know uh the commit id because there are so many  commits are there in the first commit we have only   one single line in the second commit we have three  lines so in which commit you want to compare this   content so we need to know the commit id so how  we will know the commit id so to get the commit id   we have to execute one more command here that is  called get log git lock iphone iphone one line   okay iphone iphone one line so this command  will give you the ids of every commit whatever   you have done earlier so let me just execute that  command so let me clear it get lock iphone hyphen   get lock iphone iphone one line this is the  command so when i execute this command which   will show you all the commands whatever we have  done earlier now we can just look at here this is   my first commit and this is a latest commit or the  last commit we can see now whatever code you can   see here these are the commit ids these are the  commit ids now i want to compare my file contained   from working directory to the first commit so  which commit id how to take this is the commit   id how to take sorry this is the commit id we  have to take and what is the final command we   have to write here once you know the commit id so  what is the command we have to execute now is get   diff get a diff and commit id and  then specify the name of the file   so specify the name of the file so now what  this command will do is this particular command   so here this is a commit id so whichever specific  commit which you want to compare with you have to   specify the commit id here so get diff the commit  id index.txt so this command will exactly compare   the file content in working directory and the  file content in first commit in the first commit   we have only one single line okay so let us try  to execute this command so the same command i am   trying to copy here let us paste it here all right  so now we got some output so now let us try to   analyze output here so as per the analogy  you can just look at the presentation here   so what are the changes we have in the first  commit we have only single line animals but in   the working directory we have a four lines now if  i just look at the output here okay so animal so   there is a space between there is a space here in  the prefix so that means this is unchanged that   means the same line is there in the first commit  file and the second thing is burst fishes trees   so plus is representing the destination file so  in these two what is the destination file working   directory is a destination field is always uh  console right to left so this is a source file   and this is the target or destination so here  plus is representing plus is representing your   target file so that is your working directory  file so in the working directory file these are   the three additional lines which we have added and  these three lines are not there in our repository   so there is only one common line which is already  there which is unchanged but these three lines   which we have added in the working directory  okay so this is how we have to compare our   working directory files with a specific commit  in the local repository specific commit in the   local repository so that is our requirement now  so we'll see one more requirement we can also   execute a git diff command in the different  places so for example so this is my fourth   requirement so suppose i just want to uh compare  let's see another requirement requirement of five okay so here now we can see this requirement  i want to see the difference in file content   between specific commit and staging copy  specific commit and staging copy so previously   what we have done specific commit and working  directory so specifying commit means this one   first commit and working copy now we have to  compare the specific commit with a staging file   so specific commit with a staging file so  how we can compare these two so staging file   we representing iphone iphone stage hyphen iphone  stage option right and commit so which file which   we can we can representing the commit by using  commit id so now let us write the command here   so what you have to do we can again take the  same commit id so because this is last commit   so this is not a last commit the last command is  this one second one and this old commit so i want   to compare this with with this commander so for  that what you have to do we have to write this   command like this get get diff and uh git diff  we have to compare this with our staging file so   staging file how we can representing iphone iphone  staged iphone iphone staged and then specify the   id commit id so what is the commit id the same  commit id i will specify here same commit id   we specify here and then uh do we need to  specify the file name here we don't need to   specify the file name because by default we  specify the commit id right so staged file   the staged file will compare with the commit id  so let us come back let's execute this command so let us execute this command  go back to the get and paste here all right so now stage is anywhere representing  your staging environment right and this is a id   commit id so now these are the differences which  you have shown so now let us try to understand   the differences so now we have compared stage  file content with a specific commit what is the   difference here so animals there is no change so  animals there is a space there is no change here   and birds and fishes so these two additional  lines are added in the destination file which is   a staged file so if i just look at here boards and  fishes so these two additionally added into the   staging file so by seeing this so by seeing this  we can understand the difference so space animals   means this is unchanged plus birds plus fishes  means which are the new lines which are added   in the staged file so these are the differences  between staged file and the specific commit so   like this we can compare the file content in the  different combinations and apart from this so   let me also show you suppose i want to compare  the file content between two specific commits   two specific comments so let me just add one  more requirement let us say requirement six so   i want to see the difference in the file contained  between two specified commits so let us see here i   have a two commands first commit and second commit  so i want to see the difference between these two   comments in the first commit you have only one  line in the second commit you have a three lines   now i want to see the difference between these  two specific commits so what is the command we   have to execute here is you have to execute get  diff and uh we have to specify the commit ids   commit ids of the uh both so if i just how we will  get the commit ids here so what is the command get   lock iphone one line get to log iphone one  line so this will give you committed id so   spelling wrong so get log get a log iphone iphone  one line this is one line so now this is of   latest commit this is the old commit so in the  first commit we have committed only one line   in the same in the second commit we have committed  three lines now let us compare these two so what i   will compare is i will specify the commit so  this is the first commit this is the latest   comment so file content between two specified  commands so this my commit id of the first commit   and this is a commit id of the another  command so currently i have only two commits   so i'm specifying the ids of two commands and on  which file index.txt file okay so this will give   you the differences between the file content in  two specified commits so this is a commit id of   the first commit this is a commit id of the  second commit now let us execute this command   when i execute this so now it is giving some  differences so let us try to understand this   and uh between these two commits  first commit and second commit   in the first and second commits animals is still  there there is no change that line so animals   there is a space space is representing no change  or unchanged now in the first and second commits   so minus it is showing so what is minus  representing so minus representing the   minus representing the destination oh sorry minus  is representing the source plus is representing   the destination so what is the source here what is  the destination here the source is the old commit   and destination is a new commit so minus bars  minus wishes so these two lines are missing   in the source file that is a source commit okay  so these two lines minus is representing missing   so minus bars or minus features are missing from  the first commit and which are there in the second   commit so this is how we can also compare the  content between two different comments in the   local repository and not only this we can also  use git div command or to compare the content   between or two different branches so for example  we haven't discussed about branches and remote   repositories so far in the next coming sessions i  will discuss about them but just remember this so   if you want to see the difference in content  between two branches branches in the sense what   in the repository we have only one branch so we  have created only one branch which is representing   by master branch and which is also referred as a  header and similarly we can also create multiple   branches so for example i have master branch and  test branch let us assume there are two branches   so let us assume two branches one is a master  bench one is a test branch so how we can compare   the files contents between two branches so for  that i can use one command like this simply get   git diff same command git diff and the name of the  branch master and i want to compare this branch   with another branch called test so then this  command will show you all the differences between   files which are available in the master branch and  the test branch so this command will show all the   differences between master branch and test branch  okay this is the command and similarly we can   also use a div command to compare the differences  between your local repository files and remote   repository files so far we haven't discussed about  remorse repository so once you push these files   into remote repository the files will be available  in the remote repository so if you want to compare   the files between the local repository and the  remote repository also we can use uh git git   diff command so let us see the requirement seven  suppose if you want to compare the files between   local and remote repositories then also we can use  git diff command in the coming sessions i'll show   you how we can do this so to see the differences  in content between local and remote repositories   so for that what i have to do is we have to use  a get diff master so master is a local repository   branch and here we have to say origin or url  of your remote repository so and then branch   name so always origin is representing the remote  repository so we have to pass the url actually so   that url is representing your remote repository  and inside the remote repository whatever branch   you have you can specify the branch so even in  the report remote repository also we will have a   master branch so i'm comparing the master branch  in your local repository with remote repository   master branch and this command will show you  all the differences between the files which   are available inside your local repository master  branch and remote repository master branch okay   so this is how we can use a git diff command  very very useful command to compare the files   or the differences between the files between  working directory or staging between working   directory or local repository or staging  local repository or local repository to remote   repository so we can take any of the combinations  okay so that is all about git diff command in   the next video we will see few more commands so  thanks for watching guys that's all for this video
Info
Channel: SDET- QA
Views: 74,944
Rating: undefined out of 5
Keywords: Python, Selenium with Python, Selenium webdriver, Automation, Testing tools, Selenium tutorials, Python tutorials, Manual testing, SDET, Java, selenium with java, big data, hadoop, web services, postman, soapui, rest assured, big data testing, hadoop testing, ETL testing, SQL, Programming, Software Testing material, selenium videos, python videos, automation vidios, jira, jmeter, performance testing, functional testing, QA, QC, Agile testing, SDLC, Automation Step by Step, restapi
Id: f8YUWe0De6Q
Channel Id: undefined
Length: 52min 29sec (3149 seconds)
Published: Fri May 21 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.