Thumbnail for A brief introduction to Git for beginners | GitHub by GitHub

A brief introduction to Git for beginners | GitHub

GitHub

9m 9s1,501 words~8 min read
YouTube auto captions
Transcript source

YouTube auto captions

This transcript was extracted from YouTube's auto-generated caption track. The transcript below is server-rendered so it can be read, searched, cited, and shared without opening the original YouTube player.

Pull quotes
[0:00]If you don't know the first thing about Git or version control, or the basic concepts you need to be successful with Git, then this video is for you.
[0:13]Today, I'm going to teach you everything you need to know to get started with Git.
[0:13]If you're an absolute beginner, this video will help you feel more confident in installing, configuring, and understanding Git and version control.
[0:13]You'll learn all the fundamental concepts you need to install, configure, and get started using Git on your machine.
Use this transcript
Related transcript hubs

[0:00]If you don't know the first thing about Git or version control, or the basic concepts you need to be successful with Git, then this video is for you.

[0:13]Today, I'm going to teach you everything you need to know to get started with Git. If you're an absolute beginner, this video will help you feel more confident in installing, configuring, and understanding Git and version control. You'll learn all the fundamental concepts you need to install, configure, and get started using Git on your machine. I'm Kedasha and I'm so excited that you're here with me today. If you're new to the GitHub channel, be sure to hit the subscribe button below so you don't miss any of our future uploads. Let's get into it. Now, what is Git and why do you need to know it? Well, Git is the most widely used version control system in the world. Version control is a system that tracks changes to files over a period of time. So, think about your resume for a moment. If you're like me, you may have a few different versions of your resume over the course of your career. So, you may have resume, resume V2, resume V3, and resume final saved on your laptop as four different files, and they may look something like this. With version control, you're able to keep just one main resume file because the version control system, aka Git, tracks all the changes for you as long as you save them. This means you're able to have a history where you can view all the changes made to your resume and have copies of previous versions of your resume without creating a new file every time. Okay, so now that we know what Git and version control are, let's get into some basic Git concepts that will be good to know. The working directory is where you make changes to your files. It is like your workspace, holding the current state of your project that Git hasn't yet been told to track. The staging area or index is where you prepare your changes before committing them. It's like a draft space, allowing you to review and adjust the changes before they become a part of the project's history. Your local repository is your project's history stored on your computer. It includes all the commits and branches, acting as a personal record of the project's changes. A remote repository is a version of your project hosted on the internet or a network. It allows multiple people to collaborate by pushing to and pulling from the shared resource. Branches are parallel versions of your project. They allow you to work on different features or fixes independently without affecting the main project until you're ready to merge back into them. A pull request is the way to propose changes from one branch to another. It's a request to review, discuss, and possibly merge the changes into the target branch often used in team collaborations. And finally, merging is the process of integrating changes from one branch into another. It combines the histories of both branches, creating a single, unified history. To use Git, you need to download it on your machine. So, let's do that right now. I'm using a MacBook, and while macOS comes with a pre-installed version of Git, we still want to download it so we have the most up-to-date version. Let's go to the link on the screen, then click macOS, then we'll follow the on-screen instructions. First, we'll install Homebrew. Homebrew allows us to easily install software on our machines, so let's copy this command right here. Pop open our terminals, then paste the command and hit enter. This will take a while to run, so let's give it a few moments. Once Homebrew is installed, let's return to the download page and copy the command to install Git. Open up your terminal and paste the command brew install Git. This will run the installer so we can have Git on our system. When it runs successfully, you now have Git on your machine. Open up your terminal and run the command Git, and you should see a list of all the commands available. Now, if you're using a Windows machine, let's take a look at the downloads page. Click on the Windows icon and then select the link that says click here to download, and this will give us the most recent version of Git for Windows. Once you have that folder on your machine, double-click it and follow the on-screen wizard prompts. Click next to accept the terms, click next for the location to save Git, click next to keep the default settings. Let's reset the default branch name to main though, as that's the new convention. Click next to accept the recommended path, click next to accept the bundled Open SSH program. Don't worry about that right now. And let's just click next for all the other options and then click install. Once Git is installed on the machine, click finish and open up your terminal. Run the command Git, and you should see a list of all the commands available. You're now ready to start configuring and using Git. Now that we have Git on our machines, let's configure it. Open up your terminal and type Git config --global user.name space, then your username in quotes like this. Git config --global user.email space and then your email address tells Git who made the change and gives you credit for the work that was done. If we run Git config, you can see all the other configuration options that are available, but we don't need to worry about those right now. For now, we can check our settings by running Git config --list, and this will return the configuration options we just set. Press the Q key on your keyboard to exit this screen. Okay, now that we have a basic config, let's go over some of the most basic terminal and Git commands so you can start using the tool. Let's first get started by creating a new folder. Open up your terminal and type mkdir git-practice to create a new folder. Then type cd git-practice to go into the folder that you just created. Open the folder in a code editor. Okay, great. Let's go back to the terminal and type touch hello.md to create a new markdown file in our folder. Navigate to your code editor, and you'll see the file right there, hello.md. Okay, let's go back to the terminal and type Git status. This will return an error message because Git is not initialized. To initialize Git is to create a new Git repository. This is the first command you run in a new project. So, let's run Git init in this folder, which allows Git to start tracking our changes. Then, let's run Git status again, and you'll see that it's currently tracking the empty hello.md file. Great. This will show us our changes and whether they have been staged, and it will also show us which files are being tracked by Git. Okay, now let's run Git add period. This will add all the changes from the working directory to the staging area. If we run Git status, we'll see a different color of the tracked hello.md file.

[7:27]This indicates to us that it's currently in the staging area. Go back to your code editor and type the following: # I am learning to use Git! Save the file and return to your terminal. If I type Git status, this will show me that there's been a change to the hello.md file. Let's run Git add again. Then let's create another file. touch newfile.js and now let's run Git status. As you see, one file is staged, while the other file is unstaged as indicated by the different colors. Let's commit these changes by running Git commit -m "initial commit". This command allows us to save our changes with a message attached to it. One thing to note is that you'll be using Git status, Git add, and Git commit very often while using Git. So, it's important to practice these commands. You can see a list of all the available commands by running Git in your terminal, or you can go to this website to see a list of the commands and know how to use them. Before we wrap up, quick question. Are Git and GitHub the same? The answer to that is no. Git is a version control system that tracks file changes, and GitHub is a platform that allows developers to collaborate and store their code in the cloud. Git and GitHub work together to make building, scaling, securing, and storing software much easier. Thanks for watching. I hope you found this helpful. Remember to like this video and subscribe to the channel so you don't miss any of our future videos. Happy coding!

Need another transcript?

Paste any YouTube URL to get a clean transcript in seconds.

Get a Transcript