Hello, dissidents, today we are going to a very important lesson today will learn what branches and
how to ensure smooth navigation between them.
I will explain you how comets, asteroids and get in a nutshell will answer the question, what actually
branches?
I will explain today.
What is it that after you will understand, the theory will proceed with practice exercises to learn
commands that will allow us to create new branches and navigate between already existing ones.
You learn such commands as Check-Out and Gifts, which will Ranjith branch command.
And I'll tell you how you can list all your local branches and remote.
Once you're in the practice exercises, I'll show you how you can remove branch locally and in remote
repository while navigating between the snapshots.
I will show you what the touch that state is.
Besides that, today I will show you basically next terminal commands for navigation in the file system,
creating files and listin files.
Lets start and to start with, let's imagine the case that you receive task on your work and you need
to implement it to start work on the new task.
You have to isolate your changes from the stable version of your code to make sure you will not mess
it up through the late hour code.
During the development of the new feature that allows us to create a separate branch.
What is the branch we briefly discussed?
What is the branch one?
We talked about our master branch.
But let's recap one more time and simple words unit branch to diverge from the main branch to continue
development without messing with the main development branch.
For example, here's the main development branch where the latest version of the code is stored and
you want to start work on the new task.
You create a separate branch, you create comments on that branch, and after that you merge a branch
with the development branch easy.
Meanwhile, another developer can create a new branch and work in parallel with you for some period
of time and merge his changes with years later.
That's why we need branches during the software development in a team.
To understand how branches work, we need to understand a bit deeper how get stores information you
remember that gets its files as a series of the snapshots.
When we create a command, get to commit objects that contains a pointer to the snapshot of the content
that we added to the staging area.
Also, this object stauss pointers to the comments that directly came before the current commit.
Before we start learning specific commands how to create branches, I want you to understand the theory,
at least on the high level, how it works, what actually happens when we create a new branch on this
slide, you can see that I created a new branch with the name testing what actually happened in the
language of it.
I just created a new pointer on the current commit on the moment when I create a new branch from the
master to pointers are pointing out to the same command, but how it knows that at this specific moment
of time I'm on the Master Branch, but not on the testing branch.
There is one more point.
I called that.
Now let's imagine we switched branches.
I will show you comments a bit later in this lesson when we will have practice exercise.
Right now, I want you to focus on the series and this visualization switch branches in the language
object is to change head pointer.
Now, Head is pointing out to the testing pointer being on this branch, we can create a new command.
What happens next?
Our testing branch moved forward while Master Branch still points to the previous command.
So in this particular case, if you would switch back to the master branch, you would see the state
of the file system, which was before your last commit.
OK, now you can imagine how pointers and it works, but let's move further now.
Imagine that somebody, some as a developer, managed to put changes into the master branch and then
you can meet and Master Branch appeared.
Your project history has diverged.
Both changes in these two countries are isolated from each other.
But we can merge.
This changes if we want that this exact scenario which we need to learn together.
And this course, we are going to learn how to merge changes together from different branches.
So right now, you already understand the theory of branches.
You can visualize in your mind how navigation between branches works and why do we need this now it
is time to run specific it commands that will allow you to navigate between branches.
Let's practice usually on the job.
You are going to use some task management system or issue trackers that will give you a unique idea
of your task.
Imagine that we have a task to implement logic of discount calculation for our customers based on the
history of purchases where we need to start, we need to start from creation of the branch.
There are different ways to create branches.
One of the options is to use the next command, get Branch G a three zero one.
Let's press enter new branch is created, but you see here in parentheses, I'm still in the master
branch to check which branches I have locally.
I have to just use the next command get branch to see all remoted branches.
I have to use the next command branch was option are.
And you see that right now I have only one branch and remote that is my original Austin branch.
To see all local and remote branches you have to use the EH option.
Get Branch Desh a.
And here we can find all local and remote branches, but to be honest, the branch command is rarely
used among developers to create a new branch because this command only creates branch but not get you
to the new branch.
Usually software engineers use the commands it creates and changed branches simultaneously.
So let's type the following year.
Check out, check out.
Command is for changing branches.
Option B, this option is to indicate that I want to change and create a new branch.
B stands for Branch and now let's specify the name of the branch task three zero one underscore discount.
Underscore calculation.
Usually with the task, we would like to specify a brief description of what changes will be in this
branch press.
Enter and we switch to the new branch and in parentheses you can easily identify on which branch you
are right now and where is your head pointer.
OK, we created changes.
Now let's implement our task.
For the sake of example.
I won't write any code and I will not implement any logic related to the discount calculation because
I want you now to focus only on it.
But let's imitate that.
We need some changes and all of them stored in the new file.
Let me use Linux commands to create a new file.
First of all, I want to navigate to the folder with the source code Siggie, SIRC and Presenta.
Sydney stands for Change Directory and you see here in the path that I navigated to the SC directory.
Dutch discount calculation service, Dutch Java Dutch Command allows us to create file.
This is one of the possible ways to create files with Linux terminals to check what files you have in
the directory.
Let me show you one more Linux command.
Alas, Resorption El Al.
S is a command that list files in the specific directories.
I don't see a lot of sense in reviewing all possible options for comment because most likely you want
to use them all.
I use Option L to have such formatting.
I will leave the link and attachments to this lesson about Allah's command and if you wish, you can
try different other options.
And we see that new file is created.
Here it is.
Let's also check that file was created in the File Explorer and we can also find it here.
Awesome.
We have just created a file and here it is in the SLC directory.
Before we proceed, I want to show you one more interesting command for navigation and file system.
We are terminal Siggie, dot, dot, dot, dot, dot.
Always references to the parent directory.
So in case you want to navigate one level up, you have to use this command and you see well, already
in our project directory and not in saac folder anymore.
Now let's pretend that our work on this task is completed and we need everything.
What is needed in scope of this task?
We have to create a command with our changes.
We add file to the staging area as usual, get at DOT.
Now we create command.
Gate comit dash cam, personal discount for user can be calculated.
Great, we have our committee now, a branch.
Let's check it, lock gate, lock dash to to see only last two comments.
We can see here that this comment is from Master Branch.
And here's our new comment on our new branch.
By the way, just to remind you that it shows you the history of the current branch only to watch all
committees across the repository.
You have to type it.
Look with options all like this log double dash, all towards the history of committees for the one
single branch type Gitlow command with the branch name like this gridlock g a double zero.
And do not forget, do you stop key for after completion.
OK, this information might help you in the future, and just for the reference.
Let's move on.
I can easily navigate between branches in my local repository.
We already learned the command that allows us to switch branches.
Now, let's switch back to the master branch.
You check out master.
I don't have to use the option because Master Branch already exists and I don't need to create a new
one.
And we can see that name of the branches changed here in the parentheses.
Let's check now the file lists in the SAAC folder.
Let's navigate to SASE folder, first CD SAAC and now let's use another command to list files.
Alas, that shall.
Wow.
Magic happened where discount calculation Java file, it is in another snapshot, if you don't believe
that file is disappeared.
Let me show you in the file Explorer, can you see this?
The file is disappeared.
Now you learned how to navigate between branches.
Can you navigate only between branches?
Oh, no.
You can also navigate to the specific limit how to do that.
Let me show you at the beginning.
Let's find the comet where I want to switch, get log dash three.
OK, let me switch to this cannot get out.
Zero six G, one B and Presenta.
So you need to enter a unique combination of characters so that you would understand where you are reference
into.
And now we switch to the state of this particular comet.
Right after you switch to the specific comet, you see one message that you are in the dust head state.
What does that mean?
That means we are not on the specific branch because most likely this comet is present in different
branches.
Even if you would create Comet being here, nobody would be able to find this comet other than we are
directly examining the fire because new comets won't be connected with any specific branch.
That means these changes can easily get lost once you check out a different revision on Branch.
So why then we need to check out the specific comet.
During your life as a software engineer, you might want to navigate to the specific committee to investigate
how some specific chunk of code worked in the past.
For example, in case to troubleshoot some defect.
You want to investigate how the code worked before and you want to execute this court and the market.
That's why you might want to navigate to the specific comet.
What I want you to remember is that you shouldn't do any comets in the state just investigating an experiment
in this fine.
Well, being in the state, doing the commands and the state is not the best idea.
Let's get back to our task branch yet.
Check out Geet zero zero zero one and press up two times for auto completion.
You have to press stop two times because we have a three zero one branch and a three zero one discount
calculation branch.
And Antep allows you to select the exact branch you need for auto completion.
Now, let's push it to a region, yet push our region with option.
You g a three zero one underscore and top key to autocomplete.
Nice branch was pushed to remote, new branch in remote has been created and the branch remote tracking
has been configured.
Let's check the branch in the remote repository.
Let's open a search directory.
And here you can switch branches and we can see that on our new branch, we have new file.
Click on Inside Sidestep Select Network here, you can see its history and see that our new branch is
one committee ahead of Master Branch, OK, well on how to create branches.
But at the beginning of the lesson, we also created one branch.
Let me list all branches and get back one more time.
Get Branch was option A this task branch.
I want to remove how to remove branch get branch was option.
The D stands for delete and the branch name.
We can find message that branch has been deleted, and for the sake of example, let's pretend that
I want to remove the calculation branch from the remote to how to do that.
Yet push a region was option delete and specifies a branch name here.
Press enter.
Let me open my remote repository one more time.
And when I try to switch branch, you see that I can't find my new branch here anymore.
Now you know how to remove branch locally and in remote.
But for our next lesson, let me push our branch to region one more time, because already in the next
lesson, we are going to learn how to grade pull requests and how to merge branches together.
Yet push a region was option you for this contemplation branch.
The last but nonetheless, thing that I would like to mention today is that starting from the get version
two point twenty three onwards, instead of checkout command, new command is also available to use
get switch master.
In case you want to switch to the new branch, you have to use C option like this and get switch options.
See New Branch here.
C option stands for create to navigate back to the previous branch type, the following gate switch
and hyphen and then navigated back to the Master Branch.
To be honest, I didn't.
So engineers who are already actively used to each command because it is a big habit to use Check-Out
Command for branch navigation in the community of engineers introducing Gates, which command wasn't
done to confuse developers even more.
The thing is that Check-Out commands sometimes might be used to reverse modifications, so to clearly
separate commands, Newcomen to a single goal to switch branches gets which was introduced that it.
I believe right now, you know about branch navigation even more than some senior engineers, and right
now let's recap what we have learned today in this lesson.
You learned what the branches you understand how mechanism of branch works.
Well, what is Healthpoint in it?
After we learn theory?
I showed you a few ways how to create a new branch and get ready to commit with our changes on the new
branch, we understood how we can navigate between the branches and what the Dutch had state is.
Also in this lesson we learn how to remove branches and how to use gifts which command to navigate between
them.
During the lesson you learned basically Linux commands that allows us to navigate and filesystem, create
files and leased files in that directory.
Thanks a lot for your attention and see you in the next lesson.