Git FAQ

Some frequently asked questions about common day-by-day Git operations.

Before following these guides, make sure you have a look over Git for total beginners , especially over Install and configure Git .

I’ve made a commit and put my site down. What do I do next?

Don’t panic, you can fix it in just a couple of minutes.

NOTE

Please remember that you see the site as being down because you are logged in, but for the rest of the users the site is up and running, as it’s served from cache.

When you try to access the site, you’ll receive a warning message like this one:

The site is down

Copy the error reference you see in this warning message and go to the Logs section of the Managed Hosting Dashboard to find out more about the reason your site crashed. You can search in the logs for the error reference you’ve just copied.

Search the logs for the error

In this case, it’s a syntax error, so you can simply go to that file in Gitea , click on the edit button, fix the syntax error, and save the changes.

Fix simple errors in Gitea

However, sometimes the commits are more complex, and you do not want your site to be down until you manage to solve the problems. So you need to Revert the commit that put your site down, so that your site is operational again. After that, you can create a development branch and properly work on the bug fixes.

To revert a commit, copy your instance locally. You can get the clone URL from Gitea :

Get your clone URL from Gitea

git clone https://git.presslabs.net/user/mysite-dev.git
cd mysite-dev

If you clone your site via HTTPS, you will need to introduce your Managed Hosting Dashboard credentials. If you use the SSH URL, you need to have your SSH keys set up .

Run a git log command to check all the commits that were made.

git log
commit 072f7d92de54852e8212279420dae80a35e96015 (HEAD -> development, origin/master, origin/HEAD, master)
Author: user <user@domain.com>
Date:   Mon Aug 20 16:18:18 2018 +0300

    Improved the theme

commit 3cce2c7ff81a5f8d6c6a7b0b5c1c7c1f2ad77282
Author: user <user@domain.com>
Date:   Mon Aug 20 15:54:20 2018 +0300

    Added a new feature

commit 3395683f3e320eda9e5ec57f7c81224ced6922af
Author: user <user@domain.com>
Date:   Fri Aug 17 13:30:59 2018 +0300

    Added the robots.txt file

Get the SHA of the last commit made, in this case the Improved the theme one, and run a git revert command, followed by the SHA you have just copied. This will create a new commit that undoes the changes from the commit specified.

git revert 072f7d92de54852e8212279420dae80a35e96015

Git will open a text editor to modify the revert commit message. You can also leave the default one. In case it opens Vim , which is an editor directly from a command line, you need to type :q to exit it without editing the default commit message.

Run a git push with the newly created revert commit and your site will be up and running in no time.

git push

How can I revert multiple commits?

Since the only operation possible to undo changes on a production site is to revert the commits, it can prove quite troublesome to manually revert a large number of commits.

You can revert multiple commits by specifying the range of commits you want to get reverted.

git revert master~3..master

This command will revert the last 3 commits from the master branch.

How can I install a theme/ plugin with Git?

Firstly, you need to have the archive of the plugin/ theme. You can download it from wordpress.org or from the site of the theme/ plugin.

Get the clone URL from Gitea :

Get your clone URL from Gitea

If you clone your site via HTTPS, you will only need to introduce your Managed Hosting Dashboard credentials.

Clone your site locally:

git clone https://git.presslabs.net/user/mysite-dev.git
cd mysite-dev

Unzip the plugin/theme and copy the folder into wp-content/plugins or wp-content/themes.

Now make a commit with the newly added plugin/theme:

git add .
git commit -m "Added a new theme/plugin"

Push the changes to the remote repository:

git push

Now you need to go to your wp-admin and activate the theme/ plugin.

How can I update a theme/ plugin with Git?

Firstly, you need to have the archive of the plugin/ theme. You can download it from wordpress.org or from the site of the theme/ plugin.

Get the clone URL from Gitea :

Get your clone URL from Gitea

If you clone your site via HTTPS, you will only need to introduce your Managed Hosting Dashboard credentials.

Clone your site locally:

git clone https://git.presslabs.net/user/mysite-dev.git
cd mysite-dev

Go to wp-content/themes or wp-content/plugins and remove the old plugin or theme folder.

Remove the existing plugin/theme

Then unzip the plugin/theme and copy the folder into wp-content/plugins or wp-content/themes.

Now make a commit with the newly added plugin/theme:

git add .
git commit -m "Updated theme_name/plugin_name"

Push the changes to the remote repository:

git push