This is the first in a series of blog posts around Git and a new feature coming to cPanel, Git Version Control. If you follow cPanel’s feature request site, you already know about an upcoming feature, Git Version Control. We’re designing it to make hosting repositories as easy for developers as a “Hello World!” script. Before we send the feature your way, though, we want to make sure you’re familiar with Git.
What is Git?
Git is version control software. Whenever you change Git-managed content, Git records it and stores the history of every change you’ve made. Git was designed for the Linux kernel, and it’s great for software developers. That’s not the end of what it can do, though. You can use it for any project that’s stored as files, like web design or document storage. There’s even a cPanel employee who uses it for their grocery lists!
No matter how you use Git, any number of people can work on the same project at the same time without traffic jams.
Git stores your data in databases called repositories. You can create a repository on your cPanel account, or you can copy (in Git, “clone”) an existing repository. Our Git Version Control feature will support both options.
When you work with Git, you can have a single repository for your project, or you can have a more complicated structure.
A simple Git setup using one repository.
A multi-layer setup with project-specific repositories that merge into a main repository. cPanel uses this kind of setup. It’s great for projects that have multiple teams working on different things.
Branches separate lines of development by “branching” changes off of the main repository’s history. Git’s pretty flexible when it comes to how you use branches so you can manage them, however, works best for your team. Each person could have their own branch, or everyone might work on the same task-specific branches.
Nope, this isn’t the London subway map! Just a peek at how Git branching might look over time.
You aren’t limited to working on a single branch at a time, either. Simple commands allow you to get changes and branches from the remote repository. You can also have repositories or branches that only exist on your cPanel account. You can switch between (in Git, “check out”) those branches and manage them as needed. You can grab your teammates’ changes (in Git, “pulling”) in real time, too so you can incorporate them into your copy of the project as you go.
After you make changes, you can send them up to the main repository so that everyone can access them. To do this, you need a commit.
Commits package up your changes with author information and other change history. When you commit changes, you also create a commit message to send with them. (Good commit messages make Git really useful. There are some great guides to writing good commit messages.) Once you’ve got everything in your commit, you send (in Git, “push”) your changes to the main repository.
Using Git’s full potential
This post only describes the simplest uses of Git, but there are lots of other features to take advantage of! Among other things, you can easily:
- Find the differences between two revisions.
- View a line-by-line change history for a file, so that you can locate specific changes or who the author was.
- Find log information, such as the commit author, date, and message.
- Manipulate files and changes before or after you push them.
- Solve merge conflicts when changes collide.
- Discover when bugs were introduced through advanced version comparisons (bisecting).
Often, people only use Git on the command line. cPanel’s upcoming feature will let you create and manage repositories and view change history in a friendly interface. A lot of Git’s functionality requires command line knowledge, but don’t worry! It’s easy to learn. We’re also including automatic deployment by default, to make sure that cloned cPanel-hosted repositories automatically pull new changes.
If you already use Git, we hope that this feature will knock your socks off! If you don’t, we’re hoping we can help you get started!