Welcome back, my fellow game developers.
In this video, we are going to be learning
everything about version control,
source tree, and creating repositories of our projects.
So as you can see right here,
we've created a new project
and we've downloaded source tree.
We now have a couple of commits in here,
and we actually reverted something.
We've created our initial commit,
added a cube, reverted it.
We can actually reverse this commit.
A can. So click on Yes.
As you can see, we can go back to Unity
reload and we have our cube right here.
We will be learning everything in minute detail.
So give me your entire concentration.
This is very important.
It's an extremely helpful video
or lesson and we'll stay with you
forever as long as you are committed to becoming
a professional programmer or game developer.
So let's not waste any more time and let's get started.
O k. So version control
that and put on my laser version control.
It's hard to learn.
It's even harder to teach,
but I'll try to keep it as simple as possible.
And when you get the hang of it,
trust me, it's very simple and easy to use.
Plus it's an indispensable skill
that you need to learn if you are
looking to become a professional game developer
or even a professional program.
So let's get started with what is.
First of all, it's a system that is responsible
for managing changes to computer programs.
So this means that whenever we
create changes in our programs,
we can actually save
those changes at each step of our project.
This way, we can first of all check what we did.
We can create different kinds of versions where we
can go back and change the things that we've created.
It allows for a better teamwork.
So for example, let's say you have
four or five people working on the same project,
but each one of them has
a different task that they need to create.
So version control is
a very good way of handling all of this.
And why do we need it?
Well, why we, we actually use it?
Well, we'll use it to remember previous version of
our game and have more flexibility to experiment.
Usually, game development is
a environment where you
require a lot of experimentations.
For example, you want to add some kind of
property to some kind of
game object and maybe it breaks your entire project.
So you want to always have a previous version
of your project before adding
this game breaking mechanic.
So you can always go back and start fresh from there.
So this is extremely important,
especially for game developers that always need to be
experimenting with new ideas
and things in their games and projects.
And how are we going to use it?
Well, we are going to be using
something called source tree,
and this is version control.
It allows us to create different versions.
And its first of all, it's for free.
It's very easy for beginners, very flexible,
and it has a very simple interface
that we can use as beginners.
So let's go ahead and download source tree.
Let me show you where we can do that.
If you open up
Google Chrome or any browser that you have,
simply go to Google and right in
here, download source tree.
You should find a link right here,
and it should be the source tree.
Up.
When you click on it, you go right here to their website.
If you scroll up,
you can see that you have
the option to download for Windows.
But if you are on a Mac,
make sure that you click on here and you download
source tree for Mac OS or it will not work for you.
So if you have a Mac,
download the Mac version,
if you have a Windows,
download the Windows version.
Simple enough.
Now, when you finish downloading,
you should get this file right here.
And when you double-click on it,
you should start the installation.
Now because I already have source tree,
I will not be installing it another time.
I will just take you through
the process of actually installing.
Okay, So this is
the first window that will pop up for you.
First of all, you need to agree
to the license, of course.
And you can maybe turn this off if you don't want any
e-mails your way from
source tree and et cetera at lesson.
Next thing you need to do is you
need to create an account on occasion,
you can go to at lysine and placing as
the parent company of source tree
can go ahead and create an account there,
or you can use an existing account
if you already have a Gmail.
I personally create one using Gmail.
It's much faster, It's way easier
and they don't spam you with a lot of emails.
Next thing in here,
we are going to connect it to an account.
Now, this is, of course,
we will not be doing this.
If you want to host your code on
a certain websites like GitHub or Bitbucket.
We will not be doing that,
so you can simply click here on skipped setup.
Finally, while installing source tree
will tell you that it is unable to locate get.
So in order to complete this,
simply click on Download and embedded version
of Git and continue on.
And then it may also ask you
for something called a mercurial.
Now, Mercurial is a different system, just like get.
It allows us to save different versions of our project.
We will not be using Mercurial,
so you can simply click on,
I don't want to download
or I don't want to use Mercurial.
And this should be when you finish installing.
You should have this right here.
And your, well, this window
right here when you start source tree,
if you don't simply click right here on Create and you
should get this window.
Now, this is where we actually create our repository.
And in here you can see that we
have the destination path,
the name, and the type
of version control that we want to use.
Of course we'll be using the GET.
We also have the option to create an account,
but as I've told you, we're keeping things very simple.
It's our first time,
so we will not be creating any account.
So here we are going to choose which
is the destination path of our repository.
So what, what is the project
that we are actually going to
be creating a repository for subsequent versions of.
Well, let's create our first project
that we are going to be using.
So in here that's open up the Unity Hub.
And as you can see, we already have Hello World that we
don't in a previous video that's click on New.
And let's make sure it's a 3D project.
And this is going to be our cyber spy 2087.
Let's go ahead and create this project.
So click on Create.
And I, of course,
always using my magic of
editing in order to speed up this process.
I'll see you on the other side.
Okay, welcome back.
So I hope everything worked out for you.
So now we have a new project which is cyber spite 2087.
So now that we have our project created,
we can actually go ahead and get started
with creating a repository.
Now, if we go back into our source tree right here,
we can click on Browse
and we can actually go ahead into Unity projects.
And you can see that we have
a hello world and we have a cyberspace by 2087.
So let's select this folder.
It will create a repository under this name.
If we hit Create,
it will ask a problem.
Don't worry about it. Click on Yes.
And voila, now we have actually
started creating a repository.
You have the staged files right here.
You have different kinds of knobs.
You don't need to worry about any of them for now,
just focus on the staged files,
on staged files and commit up here.
Now, if we scroll down in these onstage files,
you can see that most of them are from the library.
We scroll down to the end,
we can see some of them are Tampa 10 or temporarily.
We can see also that we have
project settings and these are
all the files that we for our project.
We also have assets in here
for unity in the scenes for example.
So this is a repository which is
a version of our current project.
Now, the problem here is, as you can see,
there are a ton and ton of files,
and B will not be needing all of them.
Well, actually we'll need almost none of them.
We will need only a certain kind of files.
So we want to be ignoring
the library and the temporary temporary files.
Why is that? Well, let me show you by opening up
the directory of our project.
Oh, okay, So this is Cyberspace by
2080 sevens directory inside of Unity project,
as you can see up here.
So we have the assets,
the library logs, packages,
et cetera, and et cetera.
Now, what is the temporary folder and what is
the library folder and why don't we actually need them?
So temporary is just a way for unity to
open up faster whenever we start the project.
And it's always created whenever we open a project.
So for example, if I go into Unity right
here and I actually close it,
you'll see that the temporary file.
Will disappear.
And even if we delete the library right now,
so let's go ahead and delete this library entirely.
If we go back into
our Unity Hub and open up cyber spy 287.
As you can see right here,
you saw that the library has been created again
and the temporary folder has also been created.
So of course, the project should
take a bit more time now to open up.
But this is evidence that
a library and the temporary folders
are not necessary for us to always commit and stage.
And what do I mean by stage?
So whenever we stage our folders,
we actually create a commit from them,
any version of them.
And library takes up a lot of space.
As you can see, if we scroll down,
it takes up most of the space and we
don't want any of them at all.
So how should we proceed?
Well, we can actually
ignore all of the folders that are under
the library by simply going and choosing
any of the folders that have library on them.
Right-click on it.
And in here you can see that we have
the option to ignore one of them.
So click on ignore.
And in here you have option
to ignore this exact filename,
ignore all files with this extension,
or you can ignore everything beneath a library,
and this is what we want.
So click on Okay.
And as you can see, everything under
library has now been ignored,
so we cannot stage it,
so we cannot save it to our newer version.
And if you scroll up,
you might have noticed that we have a new folder
in here that is the dot git ignore.
And when we click on it on the right,
you can see that it has the library.
And, and if we double-click on it,
we can actually open it up in our notepad and in
here we can add the different files that
we also want to ignore.
So what are the files that we want to ignore?
Well, there are a ton and ton of files, but thankfully,
somebody has actually gone through
all these files and created a list of everything
that we can ignore whenever creating
version controls or versions of our project.
And in order to find that file,
you can go again and to Google or the front.
Go ahead and search dot git, ignore unity.
And you should have this link right
here for the github.com.
And it will be hosted on GitHub.
If you open up this link,
it will take you right here.
So this is the dot gitignore and it's
the unity dot git ignore.
And these are all the files that we can ignore
when creating versions of our project.
You can click on row right here,
and it will open up this window or tab.
Let's go ahead and select all
of them by clicking on control a.
We will copy all of this using
control C. And we are going
to paste it in here in our dot gitignore notepad.
And now we have the gitignore notepad filled
with all the files that we will
not use for our positive 3.
We will save that using Control S.
And now back in Unity or I mean back in source tree,
you can see that when we had
the git ignore, everything is ignored.
We will stage all of that.
And when we stage all of that,
you can see that these are the files that
are going to be committed.
And these would be our initial commitment or
our initial repository version of the project.
And usually whenever you create your initial commit,
we call this the initial.
You can capitalize it,
the initial, oops, initial commit.
And we click on Commit right here.
So now if you look on the left,
you can see that we have branches under here and
we have the master branch.
Congratulations, we have created our first commitment.
Very nice. Now, let me just
show you how we will move further down the line,
even though this video has been long enough.
But I think we need to get a proper foundation
for source tree and
version control as we move through our project.
So let's say we are in our project right here.
And let's go ahead and create some kind of cubes.
3d object.
Right-click in the hierarchy.
3d object, create a cube,
and now we have a cube.
Let's scale it up a bit.
So scale it on the x,
the y, and the z.
Great.
So now we have a cube and our scene.
And now if we go into source tree,
let's save that before we go.
And it needs to save it to a certain scene.
So let's inside of scenes.
This will be our sample scene.
Sure. Sample scene, yes, replace it.
So we have this sample scene back and source tree.
Wait for it a bit, and you can see that
we have uncommitted changes.
So if we click on them,
you can see that the on-stage files are
changes inside of the scenes,
which is the sample scene.
And here you can look in detail what we've created now.
It's a bit weird right here,
but if you look closely,
you can see that we've created box collider.
And basically this represents the cube
that we've added to our scene.
So let's go ahead and stage all of that.
We can click on Commit right here and
name this added a cube.
Click on comment.
And now in our master branch,
you can see that we have an initial commit
which didn't have any cubed.
And now in our added cube,
we've added a cube.
So congratulations.
And as a final note,
this may look a bit cumbersome.
This may look a bit weird,
but don't be afraid this is very simple.
And more importantly, it's extremely important for us to
understand as we move through our project,
create versions, versions of it.
And if we ever make a mistake,
we can actually go back by
right-clicking in here, reversing the commit.
And yes, we can reverse
the commit if we go back and to unity,
it will ask us for a live reload.
We wrote, we reload,
and now we don't have the cube or any
game breaking mechanic that we've added along the way.
And now it's time for your challenge.
Your challenge is going to be to download and
setup source tree and the ignore file.
So download source tree and stall and setup everything.
Create your 3D project in Unity Hub,
setup a repository for it and source tree,
nor the library files and get
the dot ignore file and add it to your repository,
create your first commit,
and then create your second commit.
You can even go ahead and try to
maybe play around with a couple of things.
Add a cube, reversed the commit, see what happens.
Get comfortable with source tree.
And if you're having a bit of trouble,
you can pause the video on this list
of things that you need to create.
And you can also always go
back and watch the video and see
how I made everything and
follow along with me step-by-step.
So see you in just a bit.