Do you remember writing an essay on your computer and then, on each “major” change to the document, saving the same file like geography-essay.docx, geography-essay_edited.docx, geography-essay_almost-ready.docx?
That is the reason you need Git in your software project. Git helps you keep track of your changes and, if something goes not as expected, go back to a previous version of what you were doing.
A WordPress plugin is an interesting example of that.
If you are on Linux, it is most likely Git is already installed on your device. You can check it simply with this command:
git --version
The output should be something like this:

If you get an error, then Git is not installed on your system. You can check here for step-by-step instructions on how to install Git https://git-scm.com/.
If you are on Ubuntu, like me, you can use sudo apt-get install git.
After you ensure Git is running on your computer device, let’s create a directory for your project.
mkdir cool-plugin && cd cool-plugin
Once you are inside the project directory, run the command:
git init
That’s it. Git will be initialized, and the directory you have just created is the repository of your project. As simple as that.
Now, feel free to create a cool-plugin.php file, which is the main plugin file.
<?php
/**
* Plugin Name: Cool Plugin
* Description: A very cool plugin for WordPress.
* Version: 0.0.1
* Author: Obi Juan
* Author URI: https://obijuan.dev/
* Plugin URI: https://obijuan.dev/
* License: GPL2 or later.
* Textdomain: cool-plugin
*/
add_action('plugins_loaded', 'cool_init');
function cool_init(){
return true;
}
Ok, now that you have made some progress building the initial phase of your main plugin file, it’s time to “register” the changes in Git.
Before anything, let’s check the status. Use:
git status
This command will return the current status of your git repository. Whether there are changes or not, it will specify the current status. In this case, the output should tell you that the cool-plugin.php file was created and that it received some changes, but those changes are not registered yet.
So, to register those changes, we need to add the file to the staging and commit the changes.
First, add the cool-plugin.php to the staging.
git add cool-plugin.php
Then, register the changes with:
git commit -m "Initial commit. Add starting code to the main plugin file"
Hit enter, and the changes will be registered (committed).
The -m flag means message. And then, you can add any message you want in double-quotes.
I suggest you add a short description of what the changes are about. If it is only changing the version, then you can use something like “Update version”.
To make sure that the changes were committed, use again:
git status
Then it will say two important things: the current branch you are on and ‘nothing to commit, working tree clean’, which means there are no new changes to be registered.
Congratulations. You are now using git on your project.
In all honesty, there is more to it. You can create separate branches to conduct the development of a new feature, then merge them later with your main/master branch.
When you are ready to show your work to the world, you can send your project to a remote repository. That action is called pushing.
But that’s content for another post.
So for now, see you next time!