hello how are you guys hope you guys
doing well i'm dylan and in this video
let's see how you can use uh git revert
in what cases are we using git revert
so uh a usage of git revert is if you
need to
undo a change that you have already
pushed the commits uh into your
remote branch and if it is
a bad commit and if you need to undo
that
uh the git revert
is the option that you can use right so
this is how you use it uh follow me here
i have created a repository called gate
river test uh for this demonstration and
i have already nine commits in it in
that repository you have only one file
called main dot py and these are the
changes i have done recently right
now what i will do is uh i'll add a
small commit
to show you all guys and
this commit i'm not gonna undo it
this is just gonna be a normal commit
and i'll stage
changes
right now push the changes to the branch
here i'm using only one branch which is
the master you can basically use git
revert in a specific branch also
okay now i'm going to add another line
called print
um
is going to be third unnecessary
sorry commit
uh i assume that this commit is gonna be
or the the change that i have done is an
accident or change it is not meant to
push
that into the
remote repository right
let's assume that i have accidentally
committed that change now i'm going to
accidentally commit that change right
and push the changes to the remote
branch
okay now i have accidentally and
successfully
added the accidental shade that i have
done to the remote repository
now what you have to do is you have to
undo this command so there are 11
commands the latest change uh
is the commit with the message called
unnecessary commit and i need to undo
this right
so in this case you can use git driver
before using git revert you can have you
have to uh
type git log
and see the commit id of that
latest commit that you did accidentally
so you can see the first result the part
that i have highlighted is about the
commit that i uh
recently committed right
so
there is a
id along with the commit right
you have to copy this
and you need to get
out from this what you have to do is uh
just press
semicolon and q
and you will get up from this and you
can
keep on typing the commands right
okay uh now i'll type git revert
and i'll paste the
copied
commit id which i did earlier this
should be the commit that you need to
undo
i'll press enter
now you will uh see your
uh ui where you have to give a
like a message why you are reverting
this change so i'll keep it like this
and i need to get out from this right uh
so i can basically push the changes to
the remote branch right
so what i can do is uh
press ctrl c
and it will
say that type colon q a
and press enter to exit the beam right
so you can basically uh
shift plus semicolon to
give the colon and type q a
and press enter and you will exit from
that beam ui and
you can
now run any command right when you are
using git revert and along with the
commit id right
you are basically staging another commit
with the reverter change right so you
have to push that reverter change to the
remote branch
so i'll
run it push
okay i have successfully pushed the
changes to the remote branch now i'll
check the remote repository
i'll refresh the page
and you can see uh the reverter change
right
uh that i have done is x is successfully
committed okay uh i'll go to the
committee and show it to you so the line
number nine
uh which is known as third unnecessary
commit is deleted right
okay uh hope you guys understand how you
can use git revert and why you are using
it
um if you have any concerns or like if
you have any questions just leave a
comment down below
hope you guys like this uh if you enjoy
this or if this is useful just share
like and subscribe if you haven't
subscribed me
and have a great day
thank you bye see you guys in another
video