Sometimes when starting a new project, there is no time to go to the remote Git server to create the repository first there then clone it to your local machine.
Instead, it may be more convenient to start with git init and connect to the remote repository later.
When creating the remote repository to upload your work, it is possible you add some defaults as LICENSE and README. If your local repository does not have these changes, trying to PUSH your branch will end up in an error, with some general suggestion that you need a method to reconcile your branches.
Something you can do is fetch, then rebase origin <> master.
All you need to do is:
gitfetch
gitrebaseorigin/master
After that then you’ll see the files that were created in your remote repository are now merged with the master branch in your local repository.
Yesterday, May 5th, 2023, I got an email from the WordPress Plugin Review Team notifying me that my plugin submission to the WordPress plugin repository was approved.
It was no easy thing, and not on the first try (by a silly mistake from me).
I submitted it on April 7th. Almost a month later, I received an email that I needed to make corrections before the plugin could be approved.
Silly me, in the readme.txt file, I put the version of WordPress core in the Stable tag instead of my current plugin version. ** facepalm **
That was it.
I rushed to make the correction, ready to wait another 25+ days. The WordPress Plugin Review Team has been working harder than ever reviewing plugins because one of the leading team members recently left the team.
I was surprised with the approval email one hour later from submitting the changes.
I’m hugely grateful for that faster response.
I hope for the best for the WordPress Plugin Review Team and thank them for their titanic effort in reviewing all plugin submissions.
Today May 6th, I pushed my changes through SVN. Not that different from Git. Still, some stuff I need to integrate into my workflow. With practice, I’ll get the hang of it.
This experience has just made me want to submit more plugins to WordPress.org. I’ll be shipping more for sure.
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');functioncool_init(){returntrue;}
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.