thank you for the grin welcome this is
not my first dog but still it feels like
I'm giving for the first time this
awkward feeling is undescribable but
let's get started so let's team get
ulcers I just wanted to give it the get
workflow we deal with every day as
ketosis because it's yeah it's just
crazy so why I talk on Kate I'm pretty
sure like many of you want to know why
because we have a lot of resources
online and we have a lot of thoughts but
I have certain incidents which I wanted
to share I have seen a lot of developers
and some of the students have mentored
in the past they have a set of three to
four get commands written on a text file
and that they just use them so that they
can create a protic West something which
goes bi beyond those commands that's it
they try to delete there and I'll clone
for whatever it is and redo everything
and we have to admit it we must have
started off like that and not only that
um one of my friends said that I just
are like can you explain me what get is
the first time I was trying to learn
about git git is a magical tool and
there's something magic happening yes
it's a magical tool but it's what's
happening behind the scenes is not
really magic we can understand what's
happening there so with that let's get
started okay so a small introduction
about myself I am a software engineer
Salesforce a disclaimer I'm not a friend
and developer written at the end and I'm
a released lead for documentation and
communities if you have any complaints
about Docs related to humanities come to
me and I'm an ardent open source
contributor if you want to know how to
get started with any open source project
and there and that's my twitter handle
if you want to just say hello my teams
are open that's about me so some quick
things to understand about it so I don't
want to give a definition but some
things which I feel like we need
to know about get so yes we know it's a
version control system but first get
what it does it simply tracks your
content it's a simple content tracker it
tracks all the files and folders you
have in your repository that's it
and just remember that and the second
part is the dot git folder
it's a magical folder because it's
hidden but you can still find it so it
is the heart and soul of your git
repository so when you initialize a git
repository either by cloning an existing
one or initiating an empty repository
the first thing it does is create this
dot git folder and this is the folder
that stores all the data history
everything related to your repository
and when you when I say that when you
clone someone else's repository so what
exactly is happening there is it just
copies all the contents which are inside
that git folder that's it and try to
open the get folder which you have your
any of the repository and just explore
what's happening there going further
we'll be talking about some of the
important files we need to know and the
third important point which I wanted to
make sure is git is a tool which wants
to make your distributed development
workflow life simpler like every
repository in your workflow is important
and it have the capability to replace
the other one at any given point of time
so no repository is central over here
with that I want to discuss some of the
important terminology we we kind of come
across these different terms whenever we
get to see some get errors or whenever
BDD read some good documentation often
get confused with some of these so I
just want to clarify or give a clear
definition remote repository local
repository index working tree stash so I
will explain these files terms together
so that this diagram it it all it
actually define
your get workflow so let's start with
the first one remote repository people
also say it's a upstream repository or
an origin so in most of the cases your
remote repository is to which all your
team members push changes or FET changes
from and such a remote repository
actually exists on some cold hosting
sites like github gate lab or whatever
if you have an internal server forcing
yes it exists and that is called as that
is known as report remote repository now
coming to the second term local
repository git local repository is the
one which we make all the local changes
to it is in simple terms it's nothing
but your dot git folder in your computer
that's it and the third reporting term
index kit index is used as a staging
area we have we might have heard the
term staged staged area right so that's
nothing but the index area it actually
sits between your working tree and the
local repository so the significance of
this particular area is whatever file
you add into your staging area come
whenever you commit the file or whenever
you want to make a commit it will pick
the files which are there in the index
area it won't pick the files which are
in your working tree or your local
repository now it will just touch the
files which are sitting in your index
and it plays a very significant role for
example when you run git status you
usually see files in your staging area
and green text that means you can only
commit the file which is in green text
and also get status is a very helpful
command when you actually sit and read
what's going on there it will give you
all the details it will give you
instructions on how you can stay your
file and stage your file or check out
it's a very helpful command and also
when you expand the dot git folder and
see look out for the index file
it's it exists there whenever you add a
new file it will be making some changes
to that index file and if you want to
open this particular file and see what's
getting edited it's actually some weird
code I will not be understanding but yes
there'll be something in that particular
file now coming to the food term working
tree okay so this is also a very
important term it consists of what your
current your current working snapshot
when I say that if you have two
different branches if you have a feature
branch and you're working on that your
working tree will just contain the files
which are there in that particular
feature branch it won't contain the
files which are in the master branch
unless you switch so this context
switching is taken by they can take
taken care of the working tree area now
coming to the fifth the most term if
node area or terms - the only one the
only duty of stash is to keep your
working tree area a little clean so
there are certain situations where you
try to switch a branch or make some
changes when you have certain
uncommitted files in your working tree
it won't let you do that and in that
scenario you can actually save those
files into your stash area and then
reapply them whenever you want them in
your working tree and it's actually a
very helpful area it comes in handy ok
now comes another important term head
the question now is when you run git
branch some branch name
how does get know the SHA of the last
commit a it's because of the contents in
this file um head is a reference to the
last commit in the currently checked out
branch and other useful in forensics you
can get from this particular head
pointer is it determines your current
working branch so normally when you
check out to a proper branch name it
automatically moves the head pointer
along whenever you create a new comment
in that
so we will actually um see the
significance of this pointer when we
learn about branching and if you want to
know more about this particular pointer
you can simply run git log and so that's
a commit hash and beside you always see
some thumbs so what you can infer from
this is that head is actually pointing
to your master branch and your current
branch is master and there are also
other terms like origin master and
origin head
they are the pointers which are in your
upstream repository and that's where you
option repository is there so if I
actually show you a visualization of
this the box above is option depository
if you assume that it's name is origin
and those are the pointers in they're
pointing to the commits III and the box
below is what is there in your local
repository so it always carries those
remote pointers so that it will let you
know whenever your local repository is
not up to date with the option for
Satori and that's so didn't knows that
and also when you are expand and see
what's there in the head head file it
actually exists inside the dot git
folder it actually tells gate what is
the parent for your next commit and
that's how it tracks the branching and
all the magical stuff but don't worry
I'll be clearly explaining with examples
going further um and not only of
guitarists so some of the important
internals of gate which we need to know
it's nothing but the contents which are
inside the dot git folder we have
already seen what head file is index
file is there some other important
folders and files which I want to
discuss dot git slash config we how many
of you are familiar with this ok ok ok
lot of them so this is the first
internal file we
I would like to talk about because this
is where all your git configurations
related to your git goes in over here
you can define what is your option
repository is what your origin
repository is do some branch
configuration push configurations
everything goes in there this is the
central configuration file and and this
is quite important it actually sits
Center inside the target folder and now
coming to the next important folder that
is dot get slash rest so what exactly is
a ref a ref is an indirect way of
referring to a commit and you can think
of it as a user friendly alias for
commit hash we need not really remember
thee it doesn't really have to remember
the entire 40 character hash so it it
simply keeps a track of the files under
this folder and riffs are stored in a
normal text files and the dot git slash
refs directory for example if you open
the head directory the head directory
inside the refs you will have the list
of files which are nothing but your
local branches so suppose I have master
branch in my local repository I will be
seeing over there and if I actually open
what's inside the master folder there'll
be another file which contains the
latest commits in my master branch and
that's how it keeps track of branching
even this particular folder plays a role
in branching now comes to the dot git
slash objects folder this this is the
meat of the entire target or your gate
apposite ori i say that because it
contains all the files and folders which
are present in your local repository and
the files are actually stored by the
char values over here
you can see those weird characters so
the way it arranges them is like in
folder structures so you need not really
worry about that and so I would like to
discuss more about git objects because
all your data actually goes into it so
first thing it's the meat of your local
repository so that means it contains the
actual data of your get repository and
the second thing is how does get tract
or stole all your files and folders in
the form of objects and in the form of
those four different types of objects
blob tree commit and tag so I will be
talking about the first three object
four three object types and yes they are
stored by the char values as you have
seen before
okay let's take an example that we have
this particular repository and folder
structure in your local repository so we
have a root folder we have two text
files readme and make file and a slash
SRC folder and a dot C folder file
inside the SRC folder so let's see how
it actually stores them in the form of
objects so coming to the first basic
object type git stores your file
contents as blocks so it is important to
know that it just tows the contents of
your files but not the file name so the
names and modes of the files are not
stored within the block I am just trying
to repeat it again and get will only
store our blob only once so when I say
that what it means is if you have two
different file names but with same file
content block kit will be storing that
particular file as one single blob
because the file contents are saying and
what does what it also means is whenever
you try to transfer some of the blobs
from your repository to to the other
repository if it's the same blob but
coming from two different file names it
will just transfer that single blob and
then it will expand it into a different
different files and for our example
repository those files those files are
being stored as blob with different
shards now coming to the next type of
gate object
three it's all the problem of storing
the filename and it also allows you to
store the group of files together that
is the directory or folder and a tree is
nothing but a simple list of trees and
blobs combined together along with the
names and the file modes of those blobs
entries and when you actually go and
expand one of the tree object you get to
see something like this if you um it
actually contains entries of the blog
under that particular tree the file mode
charcoaled
and the file name and just try to you
know experiment with some of the tree
objects you will definitely get a get I
get an idea about it and for the same
example if you see every folder is
actually stored as a tree with whatever
file it have within it okay now coming
to the third object type commit um so we
are storing the files and folders where
exactly does the history part comes in
this is where commit objects are coming
handy so the commit object is very
simple is much like a tree it simply
points to a tree and keeps a track of
the author the the commit message and
some time stamp around it along with
that any parent commit it's pointing to
so if you if you actually open a commit
object you will get to see the snapshot
of that particular commit suppose it's a
tree and the hash along with that and if
there is any parent commit it's pointing
to the hash of that particular previous
commit along with the author committed
information and the commit message so
you will you will actually see all these
things when you try to open up these
objects and see alright done with the
boring stuff we have understood how file
stores are your data and some of the
important terms let's discuss with
discuss about some of the scenarios and
concepts with
with which we struggle every day first
thing is branching um as developers we
all know how important branching is um
in order to maintain a cleaner workflow
and if you're open-source maintainer for
any big project you definitely know the
pain of merging branches and sometimes
you know it's very important to know how
exactly get does this patching it will
definitely make your life little easier
so let's understand what how branching
is done in gating okay let's say we have
these three commits on your master
branch where my head is pointing to the
latest commit c3 let's examine the state
of a branch so how can I do that I
simply run git log so that I can see
what is exactly happening in my work
working tree so what I do I don't get
log and I get to see the list of three
commits and some important details
beside the latest commit the top one
this is the J's count for Budapest
official website app I have cloned it
and it's exposing some email ids and so
what exactly you can infer from this it
says that the head is pointing to the
master branch and you can also see your
upstream pointers along with the latest
commit hash as we have already seen now
what do I want to do next I want to
create a new branch called reactor meter
so that's the only branch name I got it
to my mind when I was preparing the
slides a sensible name so I just used it
so we can do so by running the command
as you can see git branch and the branch
name now if you want to see the list of
branches you have in your local
repository and also some important
details on what is your current branch
you can run git branch and then it will
clearly tell you that hey you're on
master branch I'm making it in green ok
now I have created a new branch
what has happened held my head pointer
is still pointing to the master but
because I haven't switched to the newly
created branch yet so let's so let's
just see what get log talks about this
workflow so when I run git git log it
still shows that the latest commit is
pointing to master we still have our
origin or upstream repository pointers
pointing to the latest commit and we
have the reactor meter the newly created
branch still pointing to the let us
commit okay
now let's switch to the newly created
branch how can I do that I'll just run
git checkout the branch name which I
have already created and you can verify
it by running it branch okay now I am
going to react to meter branch so what
has happened the head has moved to the
newly created branch so it's pointing
now
to the reactive meter now your working
tree will will be whatever you whatever
changes you make from now on will be
going into your reactor meter branch now
if I run lick git git log for this
particular workflow what what exactly it
shows you can see the difference right
so the head is actually pointing to the
reactor meet up the newly create a
branch and my master is still having
this latest commit in its workflow and
my upstream pointers are still on the
latest commits the last commit okay
awesome now we are able to create branch
we have understood how git actually
moves the pointers the significance of
the head pointer when it comes to
branching okay let's let's do something
more to it let's add some more commits
to the reactor meter branch so have
added some commits and this is how my
workflow would look look like now so I
have added C 4 and C 5 commits to my
reactor meter branch and my head is
still pointing to reactive meter branch
everything is awesome now I'll run git
log what it actually tells
it tells that my head have actually
moved little forward it's actually
diverged
it's pointing to the reactive meter
branch the LA the top commit is nothing
but the c5 which have which have shown
you in the previous diagram and if you
go to commits below you will see the
master branch it's it's somewhere behind
right so now you can we can read git log
clearly alright um now let's switch back
to master branch and see what else we
can do so have switched back ironically
check out master and I'm back on master
branch I have verified it by running git
branch command so what exactly that
commanded the check out master it
actually did two things in move the head
pointer back to the master master branch
and it reverted the files in your local
or in your working directory back to the
snapshot the master is pointing to so
this also means that the changes you
make from this point forward will get
diverged from your reactor meter branch
okay let's let's see what git log tells
now so I run git log in this current
situation hey it's bad now I won't be
seeing those top two newly added
comments on reactor meter because I have
switched completely to master and my
head is clearly pointing to the master
branch awesome now I'll go ahead and add
some commits on master branch you can
clearly see it has diverged from the
reactor meter branch and the head
pointer is yes it moved to my late newly
added commit okay awesome so far now
where exactly is my origin slash master
the are stream repository markers it's
still behind because that's where it is
in the upstream repository and the newly
added changes are in my local repository
so if you actually run git log for this
scenario you will clearly see it will
clearly tell you that hair head is
pointing to master
and the top one is a newly added commit
and my upstream markers are somewhere
behind the latest commit so awesome
everything is like going great now let's
come back to our current working state
of our working directory now if I just
want to UM change the commit c6 I mean I
just want to move the commit c6 into my
reactor meter branch I don't want to
merge them or do anything else I just
want that single commit into my reactor
meter something like this like I just
want to move it into my reactor meter
branch um here comes the concept
cherry-picking who doesn't love
cherry-picking yeah and get it's more
fun so what exactly is cherry-picking is
the act of picking a commit from a back
branch and applying it to another branch
that's it and get cherry-pick can be
very useful for undoing changes so these
are the steps how exactly can do it copy
the commit ID the commit hash switch to
the branch to which you want to apply
the commit so in my case I want to
switch to the reactor meter branch and
I'll run cherry-pick so here I do I
check out to the reactor meter branch
that's where I want to add the commit to
and then I will do the cherry picking of
the comment which is there in the master
branch okay awesome
awesome but hey I got too much conflict
yeah
when you see this message first thing do
not panic okay don't panic don't even
try to delete anything it's okay
and always remember git status is your
friend so whenever you see a merge
conflict doing something just type git
status and see what it tells it will
give you some helpful commands and
helpful steps you can do so when when I
language status for this workflow I have
clearly seen
clearly says that hey your readme dot MD
file have a conflict and what you can do
is resolve those conflict
add your file to the index area and
simply continue the cherry-picking
command so it clearly gives you the
instructions saying fix the conflicts
and run git cherry-pick - - continue
super helpful
okay never forget this command so okay
fine that's fine but how do I convert
resolve the conflict yes um using some
of the tools with which you are
comfortable is it's great but it's still
important to know how to read the
commits conflict markers so first thing
is we need to understand what git is
trying to say so anything between the
first two markers I wish this work okay
yes awesome so anything between this and
this two markers it it these changes are
actually what are present in your
currently checked out branch and
anything between these two markers are
the changes which are present in your
master branch from the cherry-picking
Komaki or cherry-picking
commit changes this these are this so
always remember anything which goes in
these two are the changes which are
locally you are on so these changes are
the first to chair this particular line
is present on a reactive meter branch
and these changes are actually present
in in the commit which is present on the
master branch okay once you know what
change you want to make sure you delete
those beard markers and also the make
sure you delete the extra all these
extra markers and also the unnecessary
change use your best knowledge and
judgment when to make to have what you
want - okay awesome now I have resolved
my conflict
continue with the cherry pick and this
is what my current workflow contains
okay so I have successfully cherry
picked this particular c6 commit into my
reactive meetup commit my head pointer
is automatically moved to the latest
commit awesome so I have all these
commits in my current working directory
okay one more thing which we need to
remember is whenever you do run
cherry-pick come command it won't delete
the this old oil commit so I don't want
that to be on master branch what can I
do first thing I will um switch back to
the master branch so if you remember I
was on the reactor meter branch I'll
switch back to the master branch because
the comment which I want to delete is on
master branch c6 so I'll switch back to
master as you can see the head is
pointing to a master branch and also
note the parent commit for c6 the
comment which I want to delete is c3
okay I run the reset command very very
helpful you know sometimes when you want
to just undo your commits you're you're
embarrassed of the commit message you
have done just run git reset so I don't
get reset - - hard head till one so I'm
saying what I'm saying is I'm telling it
to move the head pointer of one commit
backward that is moved to the pedal
commit of the command which I want to
delete and yeah that's it you will not
have the changes in your local working
directory so they are getting a lot of
arguments related to it but I will not
go further from here again one thing you
need to remember whenever you delete
this c6 commit it's it is deleted from
your branching the pointer is like
removed from it but the get arm but the
commit will be still existing in your
local directory if you actually open the
get object folder you will still see
that hanging around there so that's
where the gate GC command comes in handy
it's a garbage collector come
but get just running it removes all the
commits which are hanging around there
pointing to nothing okay the time but
this is the last one okay two minutes
merging a I won't talk about it so I
will not leave the stage without
completing this so so if you are a
maintainer of any project I feel you
okay merging is not easy so let's assume
that this is my current workflow okay I
have these comments on my reactor meter
branch and that's my master branch so
now I want to merge the reactive meter
branch into my master branch okay so how
do I do it I switch to the master branch
because that's where I want to merge the
changes into so I switched back the head
is pointing to my master branch now and
I run git merge react to meet up that's
the branch which I want to merging much
the changes from and again I warn you if
there are any merge conflicts it will
tell you and you know what to do if you
see a merge conflict right I'm sure
you're confident now and what exactly
good does is it creates a new snapshot
and it automatically creates a new
commit pointing to both of these commits
over here the commit c6 and c7 and
something which is special about c8 is
it's known as much commit it points it
has two parent commits that c7 and c6
and this once the merge is successful
the head pointer is automatically moved
to c8 and always remember if you are
done with the branch please please
PLEASE delete it it will just makes your
log looks the branching workflow looks
shitty so please remember that and the
merge which I have just shown you is a
three-way merge there there's another
type of a merge which I don't which I
don't want to talk about right now but
yeah that's about merging as a final
conclusion get is not has Gary as you
think like if you just sit some arm
sit on some git workflow and spend some
time to understand no branching and
these all day-to-day commands we run you
will become a professor and some of the
important resources yes the
documentation we are scared of it
but it's it's very useful if you
actually understand some of the terms
it's it's very useful and also the GUID
Pro book is amazing ok just Google
forget Pro book it's it's open source
it's it talks about different scenarios
merging rebasing all these different
concepts it's amazing
give it a try and hey that's how you can
tame the guitar Souris be confident in
what your command you run you can
definitely do it and that's the end
thank you
[Applause]