hi friends this is leela welcome to my
channel leela webb dev
in this video we will see the practical
implementation of this fetch command
so how the fetch command will work will
be used in the real time let's try to
see
now for this one what i am trying to do
is i am trying to create a new
repository
so with the name something like git
hyphen fetch
git fetch command now i am creating a
readme file
so create repository so git fetch
command has been created
now here what i will try to do is i will
try to create some branches nothing but
one branch i'll create login
okay and also another branch i will try
to create nothing but registration
okay so these are the two branches i am
creating
so these are the two branches now what i
will try to do is let
let's try to clone this one okay so i am
cloning
now if i go to here so now let's try to
check
let me clear out this one all okay so
let's try to check whether i am in the
repository i am not in the repository so
i can do
git clone and paste the repository here
so press enter so it will clone yeah it
has cloned so now if i try to check
so let's go into the git hyphen page
so i am in the main directory okay main
repository
so main branch sorry so let me clear it
out so here if i try to
press the ls so i am able to see only
the redmi file and if i try to see the
branches
so only one branch is there in the local
repository so if i want to check the
remote branches what are the remote
branches present
git branch hyphen r it will give me the
remote repository remote branches what
are the branches present in the report
origin login is there and the
registration is there fine but in the
local repo we have only the main branch
fine this is correct
so if i try to press git status so if i
try to do git status
it is showing that your branch is up to
date with the origin
main okay fine it's correct so now what
i will try to do is let me go to the
here and in the mask in the in the main
what i will do is
so here i will add a file something like
main main dot txt okay i have created a
file mainly
some some collaborators have created a
commits there is nothing but in the main
branch they have created a main.txt file
and here if i do in the login if i go
to the what i can say if i add a file
create new file okay login.txt
login.txt here i will
submit the file okay so in the main
branch and the login branch you are
having
so now let's try to go into here so if i
try to
press the status so it is still telling
that get up to date with the origin main
so now what we need to do so we already
know that in the main one file has been
completed that is nothing but the
main.txt file
so now i want to fetch those details so
what i need to do here
so now i need to get those details so
what i need to do here what i will try
to do is
i will do git fetch origin or otherwise
we can write only git fetch
so here what i will try to do is git
fetch origin if i do the git fetch
origin
it is telling that so in the origin main
it has got the new commit
and also in the origin login also it has
got the new commit so in origin login
also we are committed
so these are the changes we got it now
if you try to
check the status so now just our local
repo
came to know about the changes that we
got the new commits but it will not add
those commit into the local branch main
so if you try to see the git status so
what will happen here
it will be telling that your branch is
behind origin main by one commit
so it is your local branch main is
behind by one committee decide it is
selling and can be fast forward
so now what it is telling that so it is
telling that it is behind
by one commit so why because so now in
the in the
in the remote repository it has updated
to the
one commit so now if i try to check the
git log
hyphen iphone one line so you will not
able to see any commit so what what i
did the commit so create login file i
have created so here in the
in the local main branch you are not
able to see anything so now if i want to
check the ls
so here also we are not able to get this
but we can say that
login.thc5 main.txt file if i want to
know those details what are the details
i got it is so i can go to the
git checkout origin
slash main origin slash main i can go to
origin slash main
and if i try to press the ls see here
now i'm able to see the main.txt pen so
what are the changes that has been i got
from the
origin slash main i'm able to see here
the details if you want to check the log
means git log hyphen from one line
you'll be able to see that while that is
nothing but create dot main.txt this is
the latest commit what we got from the
by doing the get pitch but the local
branch main is still in the initial
commit so
the main has not updated to the latest
commit so origin slash main is in the
latest comment so that is the reason it
is telling that
origin main is ahead be a head of one
commit and your main is behind up one
committed
saying so these two origin main and the
local branch main are not in sync with
each
other it is trying to say so now i will
try to show you
another one so now let's try to switch
to the main
so now i will try to show it another one
another type of scenario now we have
already got the
latest data from the login branch answer
right
what i will try to do here so let's try
to get
switch login so i will try to switch in
the login
so now you need to know that switch it
to your new branch login and the branch
login setup track
so now it has set up the track with the
login so that means
if i try to check the status so i will
be up
it will be updated with origin login so
why because this login branch has
created just now
so when i switch this login so new login
branch has been created
local branch so that means it will
already fetch details everything will be
get into this local branch so if you try
to check the ls command you'll be able
to see this login.txt file also
if i try to check the git log iphone
iphone one line
you'll be able to see the new command
create login.txt also
so this is one specific scenario so edge
case scenario will be having
so for example see in the git branch you
don't have any branch
you don't have the registration branch
now what i will try to do
here so git switch registration so i
will move to
registration so now it has it has moved
to the new registration file
and also the it has set the tracking
with the registration origin slash
registration
now what i will try to do here so here
what i will try to do is in the
registration let's go to the
registration
and i here i will create a file okay
so here i will create
so something like register.txt file i
will create okay
now let me commit the file
so now i have committed the file so here
i have already created the local branch
so if you try to see the branch here i
have already created the local branch
now here i will do git fetch so what it
will try to do
so here we got the registration so rg
slash registration we got the latest
commit
now if you try to check the status here
okay now if you try to check the status
here what will happen
so now it will try to say that your
branch is behind origin registration by
one command
okay why because we have already created
the local branch previously only with
the origin restation
previously for the login what it has
happened after gate after fetching the
data we have created the local branch
create
a new local branch with the origin slash
login so that is the reason
so it will take the latest commits what
are the fetch details and it will show
you
but here we have already created the
registration logger branch when this
changes are updated after creating the
local branch so it will tell that it is
behind the
one commit it will be same okay you need
to understand this scenario
so now another one what we what we can
say is so for example if you if
a new branch has been created what we
need to do so for example here
if a new branch is created something
like uh password or something like that
so a new branch has been created
here so if i want to get this branch is
what i need to do so here
so if i try to check the git branch
hyphen r
so there is no password branch here so
if i want to get this password branch
base what i need to do is
so just you can do the git fetch now
what it will try to see it will
it will fetch the branch from the remote
so now if i try to check the remote
so get branch hyphen r
so here you will be able to see the
origin slash password as a new branch
also so git fetch
not only get the latest commit latest
commits and latest uh
changes and also you get the branches
newly created also remote branches now
if you want to create a branch what you
can do
so just you can do git switch
password okay so it will create the
branch local branch password and also
it will set the upstream track with the
origin slice password also
so now if you try to check the status it
will tell that it is updated with the
origin password
so this is how the practical
implementation of the git fetch
so in the next video what we'll try to
do is we'll try to get the data
into the local so how to so after
fetching the details from the origin
master
so how we can push the change how we can
merge those changes into the local
branch
let's try to see that one using the
command git pull command
okay if you have any doubts any
suggestions please post the comments
below to this video
and if you like this video please do
support me by subscribing to my channel
thank you