Getting Started with Git
Aug 14 2023 · git 2.28, console
Part 1: Getting Started with Git
Leave a rating/review
Hi. My name is Jonathan Wong, and in this course we’re going to cover the basics of gift. You don’t have to have any experience with git or other version control systems. We’ll start from the ground up and take you from an absolute beginner to understanding the concepts of git so you can use it in your daily workflow.
Let’s take a step back and look at what version control, or source control, is. Developers use the two terms interchangeably and are simply referring to, tracking changes to files over time. Because we’re developers, this typically means tracking changes to source code over time, but it doesn’t have to be source code. It could also be an image for example. Maybe an icon you use on screen, changes in one version of your app to the next.
If you’re working on a project yourself, you’ll be able to see how that project progresses over time. If you’re collaborating with others, you can see the changes that each of you have made to the project. Let’s take a look at a real world example of this.
Here I am in Google docs. I’ve created this document titled recipes that will store my favorite recipes that I want to share with others. I start simple with carnitas tacos. Let’s add one more, fried chicken. Now in building this favorite recipes, I want to have some friends contribute theirs as well. So let’s invite them to collaborate. Once I share this doc with a friend, he can start contributing as well.
My friend loves barbecue, so he adds his favorite barbecue recipes.
Let’s see what that would look like with both users opening and editing the doc. My friend is to the left, and myself, the original author of the doc, on the right, you can see if i start to create another recipe, my friend gets the same updates.
It’s as if we were sharing this same document from some central datastore.
I’ll add a sweet recipe, my favorite dessert.
I can view the history of this document and I can see the lines that I added, and the lines my friend added, and what date they were added. I can go to a specific version of the document, or a specific snapshot of the document and even name this version. Let’s name it initial revision.
Because my friend and I are sharing this document from some central datastore, he too is able to see the same history as me. He even sees the name of the initial snapshot that we named as initial revision.
What’s really powerful about version control systems, is you’re able to go back to a specific version. My friend and I talk and we decide that I’ll work on sweet recipes, and he’ll work on savory recipes. So I go back to the history, and I choose to restore to my initial revision where I had a blank slate.
I add back my favorite dessert, and as you can see on the left, I’ve clobbered what my friend was working on. He no longer has the savory recipes he was going to write the steps for.
But because of the power of version control, he can go back to the document at a specific point in time and branch off his work from there. He names his new copy savory recipes to not get it confused with what I’m working on, and can remove the sweet recipe from his list of savory recipes.
If he looks at his version history, he basically sees just two revisions. The initial point where he branched off from the main document, and the current state of the document.
If I go back to my sweet recipes list, I have the full history here. Now both of us can each work on our individual tasks of recipes to complete this book.
This is essentially what version control, is. We’re able to track changes to our files over time.
With each of your files, you’re able to see who changed it, when they changed it, and why they changed it.
Git is a version control system. It’s not the only one, but it’s certainly the most popular one these days. It has a huge open source community, they make it really easy to collaborate with other developers, has a great feature set and is constantly adding new features.
Now that you see how simple version control is from a document perspective, let’s see how simple Git is.