Laravel Newbie

#4 - To git or not to git?

Episode Summary

What is Git and why do you really need it?

Episode Notes

What is Git and why do you really need it?

In this episode I make attempt of explaining what is git. Why people use and why it is important to make yourself familiar with it. I also noticed after recording this episode that there is indeed Github Desktop client

Show notes:
Laravel Forge.
Bitbucket.
Source Tree.
Github Desktop.
VSC Git History Plugin.

Show Transcript:

Hi, this is laravel newbie episode number four and I'm your host Thomas Lotocki. So what I would like to talk to you about today is GIT the Version Control. Basically what it is. It's. A tool that you will appreciate when you actually start to code. At first it might seem like a bit overwhelming tool like everything is in the command line.

[00:00:43] You don't really understand. What's happening. What are the branches? What are the commits? What are the messages? There are some conflicts and stuff like that and you like nah, I don't need it. But believe me you do! If you are a Mac user I think the the closest thing to GIT to actually understanding simply what it is it will be a bit like a time machine for your Mac, so if you mess up a file if you mess up something in your project, you can always go back and one of the nice things about GIT is that it's very very hard to actually delete something. You you may sort of move it out of your sight, but the information about the about what was in the file will be most likely there unless you force actually delete it.

[00:01:36] So. Let's start from the beginning. Why would you actually use GIT? Well, some people would think oh, I can just FTP to my server. I can drop off my files that I have basically on my local server. It works locally. So it will also work on the on the production server. Well, that's not really the case because there is lots of things that are actually going on and also the nice thing about GIT is that you can cherry-pick basically the files you want on your production server.

[00:02:14] So for instance what you don't want on your production server would be node modules, which is basically everything that is installed by npm and a node because you want basically things to be installed specifically. In a working version for your production server and the same goes for all the packages that you will be using basically for your laravel application.

[00:02:48] So you are using composer and to install something via composer you basically do composer require and then the name of the package all of those names go to composer.json file and they're being basically stored in the in the GIT repositor, but only that file the composer.json is actually stored in the in the GIT like every package that was installed is not actually part of your repository of your GIT.

[00:00:09] So what happens basically is that you have a project and you realize okay, I can show it to others. So what do you want to do to show it you want to basically create a repository then you add all the files that you have to that repository with the exceptions of the vendor files on the node module files of the .env files and so on. I'm gonna tell you in a minute why why that is happening? And then you basically create your first commit and that commit basically sort of encapsulates all of that changes and puts them under one name which is like my first commit or something like that.

[00:01:03] Then you basically go to your server. And you say OK here is the repository you do git clone. And you actually pull in all those changes in to your production server without node modules and without vendor folder created by composer. Then you do all those commands like npm install, composer install on the production server and then everything is being installed basically on the production server, but it's it did it was not part of the GIT.

[00:01:41] And the reason why people actually do that is that it's just easier to keep track of everything that way and also with every single change that you're going to do to your GIT or every little step that you're going to add to your project you create another commit and you send you basically then pull that commit to your production server and then it's being visible the on your production server and Larval Forge is actually really good for that it automates the whole process and it actually goes one step further where you can actually set it up. So once there is any push that you actually do locally to your to your repository it automatically actually pulls that to your production server.

[00:02:40] So you don't actually have to even log into a production server. You just get like a notification. I don't know email notification or slack notification or whatever whatever else you're going to set up and you basically just get the notification that oh, yeah. I finished deploying the new code on your Forge server and and that's basically the information for you that it has been done and that's basically why people use GIT if you compare that to doing something the traditional way you would have to FTP or SCP to that to that server. You would have to grab all the files. Some files will work. Some files will not work. You will have basically problems with the versions and stuff like that and you have you want to drop. There and it's not working and you looking for the problem and so on so forth. So that's why GIT is basically such a great tool. I'm pretty sure there is a graphic interface for github.com, but you are not limited to actually using GitHub when you actually set up your account.

[00:03:53] You can go also to bitbucket, and that's from a company called atlassian and basically they also use the same technology as github. So just the address will be different will not say like https://github.com something it will just say basically bitbucket.org something else.

[00:04:18] And the reason I'm actually saying about the bitbucket is that they actually have quite a nice graphical interface that you might actually use at the very beginning of GIT that gives you actually quite nice view of your repository. So it will show you all the branches and basically where the Commits are and how they merge and what they may merge and what files were changed and stuff like that and that tool is called sourcetreeapp.com I go. I'm going to actually put that in the notes as well. So you might you might want to look at that. But to be honest with you, there are also some if you use Visual Studio code. There are also some nice plugins that I'm actually going to put in the notes and that you can just install directly there and they will actually show you a very simple view of your repository and how the history actually goes.

[00:05:17] So long story short. Don't be afraid of the GIT at the you go you will end up basically using a few simple commands over and over and over again GIT is very complex tool that could be used in a very advanced way, but it can also be used in a very simple way and can give you a very good safety while you were actually working on a project so.

[00:05:51] That's GIT.

[00:05:57] And that's it for today.

[00:06:07] Thanks for listening.

Useful links:
Podcast Website.
Follow me on Twitter.
Dublin Laravel Meetup.
Slack channel for Dublin Meetup.