Learning Library

← Back to Library

Git vs GitHub Explained

Key Points

  • Git is a local version‑control system that records snapshots of your code so you can track changes, revert to previous states, and avoid losing work.
  • GitHub and GitLab are cloud‑hosted services that run Git repositories and add collaboration features, turning individual version control into a shared platform for teams and the open‑source community.
  • Together they enable multiple developers to work on the same codebase simultaneously, merge each other’s contributions, and maintain a reliable history of all modifications.
  • The workflow is highly flexible, supporting pure local development, integration into CI/CD pipelines, automated testing, and automated build‑and‑deploy processes.
  • Most interactions with Git are done via the command‑line interface on your machine, which communicates with the remote repository hosted on GitHub or GitLab.

Full Transcript

# Git vs GitHub Explained **Source:** [https://www.youtube.com/watch?v=wpISo9TNjfU](https://www.youtube.com/watch?v=wpISo9TNjfU) **Duration:** 00:10:05 ## Summary - Git is a local version‑control system that records snapshots of your code so you can track changes, revert to previous states, and avoid losing work. - GitHub and GitLab are cloud‑hosted services that run Git repositories and add collaboration features, turning individual version control into a shared platform for teams and the open‑source community. - Together they enable multiple developers to work on the same codebase simultaneously, merge each other’s contributions, and maintain a reliable history of all modifications. - The workflow is highly flexible, supporting pure local development, integration into CI/CD pipelines, automated testing, and automated build‑and‑deploy processes. - Most interactions with Git are done via the command‑line interface on your machine, which communicates with the remote repository hosted on GitHub or GitLab. ## Sections - [00:00:00](https://www.youtube.com/watch?v=wpISo9TNjfU&t=0s) **Untitled Section** - - [00:03:07](https://www.youtube.com/watch?v=wpISo9TNjfU&t=187s) **Git/GitHub Flexibility and Trunk Development** - The speaker outlines Git’s local command‑line use versus GitHub’s web interface, highlights its integration into DevOps pipelines for automated testing and deployment, and introduces trunk‑based development where developers branch from and merge back into a main code line. - [00:06:15](https://www.youtube.com/watch?v=wpISo9TNjfU&t=375s) **Coordinating Branch Commits and Merges** - The speaker outlines committing changes to a feature branch and pushing them to GitHub, then describes a coworker needing to pull and merge the main branch into his own branch before merging his work, illustrating the workflow and potential merge conflicts. - [00:09:26](https://www.youtube.com/watch?v=wpISo9TNjfU&t=566s) **Conclusion: Git, Demo, and Next Steps** - The speaker wraps up the application demo, explains Git’s relationship to GitHub and GitLab, invites viewer questions, and encourages likes, subscriptions, and earning free IBM CloudLabs badges. ## Full Transcript
0:00What is Git, and what's it used for? 0:03What's the difference between Git and GitHub, or GitLab? 0:07I'm Nathan Hekman from IBM Cloud and  I'm going to answer that for you today, 0:12but before I do, please hit that "Subscribe" button. 0:15Now let's "git" started with an example. 0:18Let's say you work for a media streaming company 0:21and you're tasked with building a music player app. 0:24So, you want to be able to be able to play music of all sorts of genres on a device 0:32and you're tasked with developing this application with a  team of developers, right - it's not just you. 0:38How do you work with that team of developers 0:40and write code at the same time as them 0:43on the same code base or project without conflicting? 0:47Well, that's where Git and GitHub, or GitLab, come in. 0:51So, what is Git, right? 0:54So, Git is what's known as a version control system. 1:03That might not mean a whole lot to you right now, but we'll jump into what exactly that means. 1:07How about GitHub? 1:11Or GitLab? 1:14Well, GitHub or GitLab are actually hosted ... Git. 1:21So, where Git is actually the underlying  system that runs on your local machine, 1:26GitHub or GitLab is hosted maybe in the cloud, 1:29or hosted via the web, 1:32to host that Git system, as well as add a few more useful features. 1:36You may know GitHub or GitLab as a very diverse community, open source community, 1:43where developers from all over the world can work together and collaborate on different code or projects. 1:49So, let's talk about some of the benefits and and aspects 1:53of Git and GitHub and how they work together. 1:56So, first of all, it allows you to track your changes. 2:01So, you always have a state tracking exactly what changes were made at any time. 2:09Kind of going along with that, it's a historical backup using ... 2:18... basically you can think of them as snapshots,  right? 2:23So, it's it's kind of like a "Save as" button. 2:26So, you're probably familiar with that. 2:27You basically can keep a previous version and revert to it if you need to 2:32while still copying and then making changes on top of that previous version. 2:35So, if you introduce a bug or mess something up 2:38you can always go back with a historical backup that it provides 2:43and revert those changes. 2:46What else? 2:48So, maybe one of the biggest benefits that Git and GitHub allow 2:52are just team-based development. 2:54So, like we were talking about over here, 2:56it allows a team of developers to actually work on the same code simultaneously 3:02and then merge their changes in together to make progress on a project. 3:07Pretty cool. 3:10Next, it's also very flexible, 3:13so it allows you to work locally on a project 3:18or Git or GitHub can be used as part of your DevOps flows 3:24so that you can integrate your repository, which we'll talk about in a second, 3:27and your project and actually have it be part of an automated test, 3:32so kick off automated testing, or be part of your automated build  and deploy processes. 3:38So, that's a really neat aspect, it's very flexible. 3:42And then finally, so, Git is typically ... you interact with it using the command line on your local machine 3:48versus GitHub is on the web, right - it's a website, and that's how you interact with GitHub or GitLab. 3:55And, finally, a concept that I think is important to  understand 3:58about Git and GitHub, or GitLab, is that it's trunk-based development. 4:07So, what does that mean? Think of a trunk like a tree, right? 4:10So, you have this main ... you can think of main code, 4:14and you as a developer maybe will want to branch off of that main branch of code, 4:20make some changes and then merge your code back into that main branch. 4:24And, over here, you might have another developer that branches off of the main branch, 4:28makes some changes, and then merges back into that main branch. 4:32That's trunk-based development. 4:34All right, let's dive into our example and see what exactly this looks like. 4:38So, let's say that you have what's called a repository. 4:44So, repository. 4:47What's a repository? 4:49It's a place to store your code and your changes to code, 4:53and in this case it's going to be hosted on the cloud or in the web on GitHub or GitLab. 5:03And, at the same time, let's say over here that I am working. 5:12I want to work on this this code base on my local machine, right. 5:16So, how do I do that? 5:17Well, I need to do what's called "clone" this repo onto my local machine and I create, 5:26... remember our trunk based development? 5:28I create a branch of code called "Nathan-branch". 5:36So, that's where I'm going to be making my  changes to the code base. 5:40And let's say ... well, what changes do I want to make? 5:43Well, I'm a huge Bluegrass fan, OK? 5:46So, I want to make the home page of the application feature Bluegrass. 5:51So, down here, let's say that I have my application 5:57and we call this our working copy. 6:02So, this is where I'm going to actually be making changes 6:07to that working copy to feature Bluegrass music on the application homepage. 6:14Great! 6:15So, once I'm happy with those changes what I'm going to do is I'm going to actually commit them, 6:20say "commit", 6:22those changes to Nathan-branch, 6:25and then, once I'm happy there, everything's committed, 6:28I'm going to go ahead and push those changes 6:32back over to our cloud-hosted repo in GitHub. 6:38So, I'm going to go ahead and push those changes. 6:42Perfect! 6:43Happy with that, right? Let's make it a little more complicated. 6:46So, over here my co-worker, Greg, 6:50is also wanting to make some changes to the application home screen, 6:55and now he happens to be making these changes before I pushed up my Bluegrass changes back to the ... 7:02... we'll call this the main-branch. 7:09So, he doesn't have my changes yet, so when he clones down to his local machine 7:17he wants to make some changes, he has a little different style preference for music. 7:23He's a huge Rock fan, OK? 7:25And so, over here on his working copy, 7:29he's going to make the home screen feature Rock music. 7:32And so when he goes ahead and he makes those changes 7:36and then he commits them back to what we call "Greg-branch", 7:45he's happy with those changes, he wants to go ahead and merge those 7:49and push them back to the main-branch. 7:52So, let's see, what does he need to do in order  to do that? 7:56Well, he'll actually need to pull and merge whatever is in the main-branch, 8:06because at this point as he's been working I've already pushed up my Bluegrass changes. 8:10So, now he has to pull those down into his Greg-branch and merge them. 8:14Uh-oh. Guess what? 8:17There is what's called a "merge conflict", that happens right here, right? 8:27So, when he's pulling down those changes he's been modifying the same code. 8:30So, there's a conflict that he needs to resolve there. 8:33So, what does he do? 8:34Like any good co-worker he compromises, right? 8:37So, he makes the main screen of the app feature both Bluegrass and Rock. 8:42So, he makes those changes in his branch, 8:45and he's ready to actually get those back in the main-branch. 8:48So, the next step he needs to take is: 8:51he needs to submit what's called a "pull request". 8:58You may have heard folks talk about a "P.R.", right? That's what a pull request is. 9:04What is it? It's basically 9:06a way for him to say, "Hey, these are the changes that I want to make", 9:10and it can be viewed in GitHub or GitLab 9:13so that anyone on the development team, like Nathan, 9:16I can go ahead and look at those changes and I say, "Good job Greg, looks great!" 9:20And I can approve the pull request and then get those changes merged into the main-branch. 9:26So, you'll see the final version of the application looks awesome, 9:30Bluegrass and Rock both featured on the main page. Awesome! 9:34So, hopefully this makes it clear about what exactly Git is, 9:39how is it related to GitHub and GitLab, 9:41and how they are fundamental to developing applications not only by yourself, 9:47but as a team of developers. 9:49Thank you. 9:50If you have questions please drop us a line below. 9:53If you want to see more videos like this in the future, please like and subscribe. 9:58And don't forget, 9:58you can grow your skills and earn a badge with IBM CloudLabs 10:02which are free, browser-based interactive Kubernetes labs.