This is the first in a series of blog posts around Git and a new feature in version 72, Git Version Control. See the full list of entries in this series at the end of this post!
If you follow our feature request site, you already know about our 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 a 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. Our 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 start.
A note from benny:
Want to be involved in the development process? Post your ideas, comments, and questions on the feature request. You can also join us in our slack or discord channels, post your questions on the cPanel forums or subreddit, or come visit Houston, Texas for the 2018 cPanel Conference, October 1st – 3rd. Need to catch up on the previous posts about Git Version control? Here they are!