If you’ve researched or experimented with coding for WordPress, you may have heard of git or GitHub. These tools can be very useful for developers, but determining what they do and the differences between them can be confusing.
Fortunately, once you understand the functions of both git and GitHub, you can put them to work in order to streamline your development process. You can even integrate the two and use them in conjunction.
In this post, we’ll outline the uses of both git and GitHub. We’ll also explain who owns each platform, and discuss how to use them together for version control and collaborative development.
Prefer to watch the video?
An Introduction to git and Version Control
First, let’s take a look at git. This is a version control software for developers:
Version control refers to the process of saving different files or ‘versions’ throughout the various stages of a project (check also: WordPress version control). This enables developers to keep track of what has been done and return to a previous phase if they decide they want to revert some of the changes they’ve made.
This is useful for a variety of reasons. For example, it makes it easier to resolve errors and fix other mistakes that might occur during development. You can also note changes in each version, to help any team members stay up-to-date on what’s completed and what still needs to be accomplished.
Unlike most other Version Control Systems (VCSs), git stores each saved version as a ‘snapshot’ instead of a list of changes made to each file. You can reference old snapshots whenever you need to and new snapshots are created when your project is modified.
Git also enables you to ‘push’ and ‘pull’ changes to and from installations on other computers. This makes it what is known as a ‘Distributed Version Control System’, and enables multiple developers to work on the same project.
However, there are a few drawbacks to handling development this way. As local software installed on your individual machine, git cannot read the edits other developers may be making in real-time. This means that if you and a teammate are working on a project simultaneously, you won’t be able to view each other’s work.
So if you aren’t completely sure when team members will be working on your project, git is best for individual use. You can then avoid conflicts, or having someone else accidentally override your code.
The Difference Between git and GitHub
GitHub makes it easier to collaborate using git. It’s a platform that can hold repositories of code in cloud-based storage so that multiple developers can work on a single project and see each others’ edits in real-time:
Plus, it also includes project organization and management features. You can assign tasks to individuals or groups, set permissions, and roles for collaborators, and use comment moderation to keep everyone on task.
Additionally, GitHub repositories are publically available. Developers from across the globe can interact with and contribute to each other’s code in order to modify or improve it, which is known as ‘social coding’. In a way, this makes GitHub a networking site for web professionals.
There are three primary actions you can take when it comes to interacting with other developers’ code on GitHub:
- Fork: The process of copying another’s code from the repository in order to modify it.
- Pull: When you’ve finished making changes to someone else’s code, you can share them with the original owner via a ‘pull request’.
- Merge: Owners can add new changes to their projects via a merge, and give credit to the contributors who suggested them.
Especially for newer developers who are trying to build up their resumes, this can be a great opportunity to gain some experience. GitHub enables you to share projects on your profile and keeps a timeline of all the ones you’ve contributed to as well.
To sum up the difference between git vs GitHub:
- git is a local VCS software that enables developers to save snapshots of their projects over time. It’s generally best for individual use.
- GitHub is a web-based platform that incorporates git’s version control features so they can be used collaboratively. It also includes project and team management features, as well as opportunities for networking and social coding.
Understanding GitHub vs GitLab
GitHub isn’t the only git repository you may want to consider if you’re looking to collaborate on a development project. GitLab is another, very similar platform that’s also worth a look:
Like GitHub, GitLab enables you to store code and use git’s version control capabilities. However, it also provides more nuanced user permissions and includes built-in Continuous Integration (CI). This eliminates the need for the pull requests used in GitHub.
With that said, GitLab is still not as popular as GitHub. With 40 million users, GitHub provides far more opportunities for networking, social coding, and even learning from other more experienced professionals in your field.
In short, both platforms are useful, but for slightly different situations. If you’re not interested in working with developers outside of your team, GitLab may help to speed up your workflow a bit. However, GitHub may be the better route for those looking to grow their careers.
The Ownership and Cost of git vs GitHub
Since they are so closely related, it would make sense if git and GitHub were owned by the same company. On the contrary, git is open source software, while GitHub is owned by Microsoft.
Open source platforms – including git and WordPress – are free to use, modify, and distribute.
GitHub’s pricing model is different, but it provides an interesting free plan. In fact, all of the core GitHub features are free for everyone (in the past the Individual Pro plan was $7 per month). For teams, pricing starts at $4 per user per month. You can also look into Enterprise pricing options for larger groups that need more advanced features.
How to Integrate git and GitHub (In 5 Steps)
In order to use git and GitHub together for version control and collaboration, there are a few steps you’ll need to take. Let’s take a look at how that process works.
It’s important to note that you do have to use git in order to take advantage of GitHub, so you’ll want to brush up on your skills with the former before trying to integrate the two. We’ve also included some basic instructions below to get you started.
If you’re already using Git, you can skip down to Step 2. On the other hand, those new to this version control software will need to install it and add some code before moving on.
Step 1: Install git and Add a Repository
First, download the git software for your Operating System (OS):
Once it’s up and running, there are a few terms you’ll want to familiarize yourself with as you start using the software:
- Repository: The file location where your project is stored.
- Commit: The command used to save new changes to your project in the repository.
- Stage: Before you can commit changes in Git, you need to stage them – this gives you the chance to prepare your code before formally adding it to your project.
- Branch: The part of your project you’re actively developing.
Step 2: Create a GitHub Account
Next, you’ll need a GitHub account. You can sign up for one for free or invest in a paid plan:
A free account works well for new developers looking to hone their skills. A pro plan is better suited to freelancers and advanced coders, while agencies will want to invest in a team plan in order to access more project management and communication tools.
Step 3: Add a GitHub Repository to Your Account
After you’ve created and set up your account, you’ll need to create a repository in GitHub where you can store your project when you move it over from git. You can do so by clicking on the relevant link in the left-hand sidebar:
Need a blazing-fast, secure, and developer-friendly hosting for your client sites? Kinsta is built with WordPress developers in mind and provides plenty of tools and a powerful dashboard. Check out our plans
Then, you’ll need to choose a name for your repository:
You can also decide if you want the repository to be public, so other GitHub users can find and contribute to it, or if you want to keep it private.
Either way, since you’ll be using an existing project, make sure to leave the Initialize this repository with a README box unchecked.
Step 4: Push a Repository to GitHub
Next, you’ll have the option to add code to your repository in a few different ways.
Since you’ve already set up your git repository, you can use the push an existing repository from the command line option:
The clipboard icon to the right enables you to copy the commands listed here, so you can quickly paste them into your preferred command-line interface to create your GitHub repository.
Once that’s done, refresh your GitHub page:
You should now be able to see your repository in GitHub. From there, you can start making changes to your project online.
It’s also possible to send and merge pull requests, and use any other tools included with your plan.
Step 5: Pull Your Changes Back to git
While you can see all the changes you and others have made to your project on GitHub, the platform doesn’t have direct access to your computer’s files. In order to keep your project up-to-date on your computer, you’ll need to pull your edits via git.
To do so, simply enter git pull origin master into your command-line interface. This should update your files so that everything is in sync across all iterations of your project.
While understanding the difference between git vs GitHub can be a little confusing at first, once you get the basics down they’re both invaluable for development purposes.
To integrate git and GitHub, you should follow these steps:
- Install git, add a repository, and create a commit.
- Create a GitHub account.
- Add a GitHub repository to your account.
- Push a commit to GitHub.
- Pull your changes back to git.
If you’re working with a team to build a website, version control and sharing can be vital.
If you enjoyed this tutorial, then you’ll love our support. All Kinsta’s hosting plans include 24/7 support from our veteran WordPress developers and engineers. Chat with the same team that backs our Fortune 500 clients. Check out our plans