• Tracking and Staging Files
• Making a Commit
• Visual Editor
• GUIs for Git
Command-line interfaces (
To use Git on your
Git is free to download: https://git-scm.com/
Recently, text editors have created a lot of support for Git. Both Adobe Dreamweaver and Microsoft’s Visual Studio Code support it.
It will also work in CLIs locally installed in other software running on your computer: I’m thinking of the CLI tool built into Desktop Server.
1. Creating a Repository
Port 22 is the secure shell access (SSH) port for connecting to the remote server your WordPress application is hosted on.
Hence -p 22 (port 22) is the command we will use to make a secure shell access request to our website:
ssh -p 22 firstname.lastname@example.org
If you are using a service like cPanel, the username and password will be set up with the cPanel account. You can also create additional accounts in Cpanel in the Web Disk tool.
However, I do recommend using a Linux server and MacOS to create SSH keys to access and install Git on your remote server. (Anyways!)
Once you are logged into the server you will need to navigate to the folder (your public
Initialize Git in that folder.
Now, when using git there has to be an origin source.
In GitHub, create a new repository that is empty. This will be where you will
We want that empty repository to be where we commit changes.
git remote add origin https://github.com/GitHubUsername/git-repository.git
Now you’re up and running.
2. Tracking and Staging Files
Do you want to track the status of every file in WordPress? Probably not.
Navigate to the WordPress folder you want to track commits in.
Once there, run a git status to make sure all the files are being tracked that you want to establish version control for.
For example, it’s probably a good idea to watch problem plugins or child theme folders.
You can either add all the files in the current folder
git add .
or specify specific files.
git add wp-config.php
3. Make a Commit
First, we commit the files we just added to be tracked.
git commit -m 'this is where the message goes'
We can also just to commit all modified or deleted files
git commit -a -m 'all the changes'
Next, we have to specify a remote depository (GitHub) that will be our origin.
The URL will be shown in the depository’s Clone or download button in GitHub.
git remote add origin https://github.com/GitHubUserName/git-depository.git
The initial commit should be to this origin on the master branch.
git push -u origin master
Often times in command-line this will bring up the Nano Editor.
Type a message in the top of the Nano Editor above the commented out stuff to leave a message about what this commit is about.
Depending upon your setup you can then write out (
Write out and quit requires you to hit escape to bring the cursor to the bottom of the message. When it does, type
4. Pulling Changes from GitHub
Once you are tracking files git will keep track of added, deleted, and modified files.
To see only modified files type:
git ls-files -m
When you run a git status it will show these files separate from untracked files.
At this point you have a decision to make. Do you pull down changes from your GitHub repository first or commit the changes on the current installation and push them to the GitHub repository.
To pull changes down from the GitHub repository use this command:
git pull https://github.com/GitHubUsername/git-repository.git
To commit changes from the currently tracked files type this command:
git commit -a
5. Visual Editor in Terminal
Who cares right? You’re using command line.
Well if you are writing a lot of code you will care, but anyways…
Navigate to the folder where there is a file you want to open. (For example, I am using a CSS file).
The default editor for UNIX operating systems is the visual editor. It is invoked using this command:
Not saying you will never use it, but let’s take a look at some of the GUIs.
To exit Visual Editor without making changes to the file, press Escape. The cursor will move to the bottom of the document. Then type:
To simply view the contents of a file in Terminal without opening Visual Editor type:
6. Git GUIs for Desktop
My personal favorite is SourceTree from Atlassian. Nothing like seeing everything big, bold, and colorful.
SourceTree can connect to multiple Git services like GitHub through API.
And obviously, GitHub Desktop.
I consider it a must-have if you are using GitHub. While the interface is not as bright as SourceTree it does work easily.
8. If all else fails 🙂
If something goes wrong and you want to erase Git from the folder where you installed it use this command:
rm -rf .git