Fixing JetPack related posts not showing for XMLRPC parse error

JetPack related posts are not showing, WordPress says This site cannot be accessed, and xmlrpc test shows parse error. not well formed . Here it shows you how to fix it.

Test your site

Run below command to test your site in an terminal (Any computer is fine.)

$ curl -A "Jetpack by" -d "<methodCall><methodName>demo.sayHello</methodName></methodCall>" https://www.your

The correct result should be:

<?xml version="1.0" encoding="UTF-8"?>

It is a XMLRPC parse error if the response is:

<?xml version="1.0" encoding="UTF-8"?>
          <value><string>parse error. not well formed</string></value>

Tips: You can also test your site using Just input your site and click Check button. Other information like username and password is not needed.

If it is an XMLRPC parse error, the result will be:

Code      Description
-32700    parse error. not well formed

Solution for parse error

Connect to your website host, run below command to install php-xml:

$ sudo apt-get install php-xml

If your host does not have apt-get installed, you may need use (Such as AWS EC2 with Amazon Linux 2):

$ sudo yum install php-xml

Retest your site, it should be OK (Restart your apache sever if needed). After your posts are synced to WordPress site, you may see related posts.

Note: Related posts will not appear unless at least 3 good related posts can be found by JetPack. See more on jetpack related posts.

Tips: For other JectPack connection issues,fix them according to fixing jetpack connection issues.




  • Partial clone

    How to clone only part of commits of a huge repository



  • Stash changes

    How to save changes temporally, apply changes, list stashes, delete a stash?




  • Remote management

    How to add a remote, delete a remote, change the URL of a remote, etc.


  • Differences

    How to check differences between working tree, index, a specific commit?




  • Check log

    How to view the last several commits, search the commit history with string, list the commits graphically, check which commit changed a string, etc.

Deleting files from Git commit history

If you commits an sensitive file or a huge unwanted file, you may want to remove it from every commit. Git provides a nuclear-level command git filter-branch which allows you rewrite the history.

git filter-branch executes the specified command for each commit specified by you and generates new commits.

Before you start, you must keep it in mind that this operation changes the existing history. If it is a public repository and someone have did some work based on the commits you want to rewrite, you’d better not do this. If you have to, remember to notify them to run git pull --rebase command.

Delete a huge folder from every commit

Here is an example of how to remove a huge folder from each commit which is committed accidentally at first.

You’d better test below commands in a temporary repository to make sure that they work properly for your git version. It is met that git filter-branch below removes the folder in working tree as well but it should not.

We do it in a new testing branch, when the result is what we want then reset it as the prior branch.

# Do it in a new testing branch
$ git checkout -b test

# Remove 'build' folder from every commit on the new branch
# --index-filter, rewrite index without checking out
# -r, remove recursively in subfolders
# --cached, remove it from index but not include working tree
# --ignore-unmatch, ignore if files to be removed are absent in a commit
# --prune-empty, remove empty commits generated by 'git rm' command
# HEAD, execute the specified command for each commit reached from HEAD by parent link
$ git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch build' --prune-empty HEAD
Rewrite fee4b8ee9df321a877cd2663b20b293eea4a1f8c (1/2)rm 'build/'
Rewrite 63f272ab5152c66693614efae77567799837c6e0 (2/2)
Ref 'refs/heads/test-filter' was rewritten

# The output is OK, reset it to the prior branch master
$ git checkout master
$ git reset --soft test

# Remove test branch
$ git branch -rm test

# Push it with force
$ git push --force origin master

If you changed commits in remote repository, remember notice other members execute below command:

# Tell others to execute below command if you changed commits in remote repository.
$ git pull --rebase


  1. If --ignore-unmatch option is not added, it will fail when the files to be removed do not exist in a commit.
  2. The files you removed will stay in disk for a while, they will be removed entirely in the next automic garbage collection of git.

Tips: To avoid adding unwanted files accidently, you should ignore it.

Other useful options:

# Execute the specified command for the last 5 commit
$ git filter-branch --index-filter 'git rm --cached --ignore-unmatch user.pem' HEAD~6..HEAD

# Execute the specified command for all branches
$ git filter-branch --index-filter 'git rm --cached --ignore-unmatch user.pem' -- --all

# Update tags when executing filter-branch, remember to push them to remotes afterwards
$ git filter-branch --index-filter 'git rm --cached --ignore-unmatch user.pem' --tag-name-filter cat HEAD

# Remove empty commits generated by 'git rm' command
$ git filter-branch --index-filter 'git rm --cached --ignore-unmatch user.pem' --prune-empty HEAD

Remotes management in Git

In Git, you can have more than one remote repository. git remote command is used to manage them. Operations illustrated include how to add a remote, remove a remote, view a remote’s information, change a remote’s URL, etc.

Add a remote

# Add a remote
$ git remote add <name> <url>

# Examples:
# Add a remote named test
$ git rmeote add test

Note: When you clone a remote repository, Git sets the remote as origin for you automatically.

List remotes

# Show remotes with names
$ git remote

# Show remotes with names, urls
$ git remote -v
origin (fetch)
origin (push)

Change URL of a remote

# Chang url of origin
$ git remote set-url origin

Verify its URL has changed:

$ git remote get-url origin

Get URL of a remote

# Get the url of origin
$ git remote get-url origin

Fetch updates from a remote

# Fetch updates from the remote named origin
$ git remote update origin

Rename a remote

# Rename a remote
$ git remote rename <old> <new>

# Examples:
# Rename origin to main
$ git remote rename origin main

Remove a remote

# Remove a remote
# Note: all the remote-tracking branches and settings 
# for the remote are removed.
$ git remote remove <name>

# Examples:
# Remove the remote nameed server2
$ git remote remove server2

Useful git commands with examples

Here it gives some useful commands with examples. These commands cover most of the usage scenarios in your daily use of git. With them, your experience with git will becomes much more easier.

Here are commands covered in this article.
– git config
– Config common used command alias
– Config editorConfig default commit template
– Config Beyond Compare 4 as your difftool
– Add .gitignore to ignore files
– git stash
– git reset
– git revert
– git cherry-pick
– git diff
– git difftoo
– git format-patch
– git show
– git log
– git grep

git config

git config can be used to get and set options in a repository or globally. Below are several useful examples to set your repository.

Config common used command alias

You can config some alias of commands to make them simpler to type.

# Use alias "git co" instead of "git checkout"
$ git config --global checkout

# Use alias "git st" instead of "git status"
$ git config --global status

# Set "git last" as a alias to view the last commit
$ git config --global alias.last 'log -1 --oneline HEAD'

# Set "git unstage" as a alias to undo the changes in index
$ git config --global alias.unstage 'reset HEAD --'

Config editor

# Config vim as your editor
$ git config --global core.editor vim

# Config notepad++ as your editor
$ git config --global core.editor "'C:/Program Files (x86)/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"

See more tools as text editor in git.

Config default commit template

Step 1: write your own git commit template file. Such as file ~/.gitmessage and put below contents:

Subject line (try to keep under 50 characters)

Multi-line description of commit to explain
what, why and how this change is being made
(try to limit each line under 72 Characters)

Provide ticket numbers or links to other relevant resource
[Ticket: #53]

Step 2: config it as your commit template:

# Config a custom commit template
$ git config --global commit.template ~/.gitmessage

See setting commit template for how to write ignoring rules.

Config Beyond Compare 4 as your difftool

# Config Beyond Compare 4 as difftool

$ git config --global diff.tool bc4
$ git config --global difftool.prompt false
# Note: set parameters for Beyond Compare tool
$ git config --global difftool.bc4.cmd '"C:Program FilesBeyond Compare 4BCompare.exe" "$LOCAL" "$REMOTE"'  

Add .gitignore to ignore files

In fact, setting up files to ignore does not use git config command.

To set up your.gitignore file:

Step 1: create a file named .gitignore in the root of your git repository. Put your ignoring rule in the file, below is an example:

# ignore all .class files

# ignore all .log files

# ignore build folder in the root directory

Step 2: commit .gitignore to make it take effect:

$ git add .gitignore
$ git commit

See ignoring files in git for more.

git stash

git stash can be used to save changes away temporally (it store them on a stack) if you don’t want to commit yet. It is very useful when you need to pause the task in progress and checkout to another branch for a more emergent one. Below is your work flow with git stash:

# Stash your work on current branch, let's call it develop
$ git stash

# Checkout to topic branch for the emergent task
$ git checkout topic

# After you finish your work, execute add and commit 
$ git add .
$ git commit

# Checkout back to the prior branch
$ git checkout develop

# Apply changes you have stashed before
$ git stash apply

# Continue your work on develop branch

Other examples:

# Apply the top stash on the stack
# Note: staged changes in the stash are not restaged 
# and stash is removed from stack.
$ git stash apply stash@{0}

# Revert working tree and staging area
$ git stash apply --index

# Repplay a stash and remove it from stack
$ git stash pop stash@{0}

See stashing changes for more usages.

git reset

git reset can be used to reset current HEAD to point to another commit. By using different options, you can control the reset degree, such as commit, index, working tree.


# Discard the last commit. 
# The commit's modifications in working tree are kept.
$ git reset HEAD~

# Discard the last commit.
# The commit's modifications in staging area are kept.
$ git reset --soft HEAD~

# Discard the last commit. 
# The commit's modifications in working tree are not kept.
$ git reset --hard HEAD~

git revert

git revert can be used to revert a commit that has been pushed to remote repository. This command does not change the history but makes a new commit which reverses the modifications.

# Undo a commit that has been pushed. 
$ git revert -m 1 HEAD

See more about undoing operations.

git cherry-pick

git cherry-pick applies changes introduced in some specified commits. With this command, you can make a new commit with the changes got from another commit :


# Apply the changes introduced by commit 95f2137 and
# create a new commit with the change
$ git cherry-pick 95f2137

# Apply the changes introduced by tip commit of develop branch
$ git cherry-pick develop

# Apply the changes introduced by tip commit of develop branch 
# in working tree and staging area, but not commit the changes.
$ git cherry-pick --no-commit develop

See more examples on copying changes from another commit.

git diff

git diff shows difference between commits, staging area and working tree. Its output can also be used to generate a patch.


# Difference between HEAD's parent and HEAD
$ git diff HEAD~ HEAD

# Difference between HEAD's parent and HEAD for index.php
$ git diff HEAD~ HEAD -- ./index.php

# Difference between working tree and HEAD
$ git diff HEAD

# Difference between staging area and HEAD
$ git diff --cached HEAD

# Create a patch from difference
$ git diff HEAD > patch-issue-53.patch

# Apply a patch generated by git diff output
$ git apply -v atch-issue-53.patch

See showing differences for more examples.

git difftool

git difftool shows difference in a visual tool (see set beycond compare as your difftool). It accepts the same options with git diff.


# Difference between HEAD's parent and HEAD
$ git difftool HEAD~ HEAD

# Difference of index.php between working tree and HEAD
# Note: if there is no difference, nothing is output.
$ git difftool HEAD~ HEAD -- index.php

See showing differences for more examples.

git format-patch

git format-patch generates patches containing submit information which can be used to email submission.

# Create patchs for commits since <commit> to the current branch tip commit
# Note: the specified commit is not included
$ git format-patch <commit>


# Create a patch for the commit HEAD
$ git format-patch HEAD~

# Create patches for commits HEAD~2, HEAD~, HEAD
$ git format-patch HEAD~3

# Create patches for a range of commits: HEAD~ and HEAD
# Note: it prepares each commit with its patch in one file per commit.
git format-patch HEAD~2..HEAD

# Apply a patch created using format-patch
$ git am 0001.patch

git show

git show can be used to show content of objects like a commit, a stash, etc.


# Show contents of asset/css/style.css in commit HEAD.
$ git show HEAD:asset/css/style.css

# Show changed files in commit HEAD
$ git show --name-only HEAD 

# Show content of the top stash
$ git stash show stash@{0}

git log

git log can be used to view and search the commit history.


# Show commit history in short format with one log in one line
$ git log --oneline

# Show only the last two commit logs
$ git log -2

# Show commit logs that are made after 2018-12-01
$ git log --after=2018-12-01

# Show only those commits that add or remove string of "update_post_meta"
$ git log -S update_post_meta

# Show only commits made by john
$ git log --author john

# Show all commits of branches in a graph structure
$ git log --all --graph --oneline --decorate

See more about viewing git history.

git grep

git grep is highly useful when you need to do a search in your git repository.


# Grep "Device is HD capable" in .xml files of current directory
$ git grep 'Device is HD capable' -- './*.xml'

Tips: By adding limit arguments (like path and file extensions), you can highly reduce the running time of git grep command.