Git is a powerful tool we use to track and share Drupal code. Go ahead and watch this video and don't worry about following along on your own. He will go into more detail and cover more commands than we usually use. This gives you a great introduction to git and how to use git. We will do some hands-on with git together.
Before you dive into the video let me cover some of the "big ideas" and the commands we use.
Git Big Ideas
A repository is a collection of branches and all the supporting code saved in "one" location. There are two primary types of repositories; remote and local. This is a HUGE core understanding of git. The remote repository is the shared repository where everyone pushes and pulls code to and from. The local repository is the collection of branches on someone's individual computer.
A collection of code kept together. For us, it will be a version of all the code relating to an individual site.
It is the branch that is currently the lead branch that is being used on the website itself. All of the other branches are working branches. The Master branch is the branch that the website is using. Master is the main branch.
This is a command the pulls all the branches and their updated code from the remote repository to your local repository. This is a vital command to run in your Ubuntu in the website project before you do any other work on the website's code. A good habit to get into is to open Ubuntu, change directory to the website you want to work on and immediately type "git pull". This will pull from the remote repository to your local repository. This will mean you will be working on the most up-to-date version of the code.
This command tells git to track the changes you have made locally to your code to your local branch.
The command places your changes in your local repository and provides a comment along with the commit.
This is the command that will send your local branches and changes to the remote repository. This is a powerful and dangerous command. If you have been working on a branch locally and have totally destroyed the site no damage has been done to the "live" site. Right now it is just on your computer. Once you git push, you have now placed your destructive code onto the remote repository and "live" site. With this said, it is not quite as dramatic as I have made it sound. There are ways to recover from this so WHEN you do this, don't worry. Stop, take a deep breath, and we will fix it. Just know, until you git push, all of the changes you have made are just on your machine.
Now, in the video he will cover many more commands, but we rarely if ever use them. The commands I have listed about are the bulk of the commands we use. With this said, I think the context he gives you in the video is a huge help in enabling you to understand what is going on with git when you use it. Before you dive into the vide, take a look at the diagram below and then watch the video.