Git: how to re-push changes already pushed, but lost due to re-creation of staging version

We use WPEngine to host WordPress sites and push changes via Git to a staging version of the site – these can then be deployed to the production version via an internal script.

We staged the live site a few days ago and pushed up a number of changes via Git to the staged version.

Read More

Accidentally, one user pushed the button to recreate the staged version of the site and all our changes were lost – Git thinks that the local and remote are up-to-date – but of course, the staged version now shows the files in the form they are on the current live site.

Is there a way that we can force push up commits from the last x days or between two set hashes – or some other correct way to notify Git that the changes are no longer in sync?

Thanks!

Related posts

2 comments

  1. git push <remotename> <commit SHA>:<remotebranchname> should do the trick, provided <remotebranchname> already exists on the remote. If it doesn’t, use git push <remotename> <commit SHA>:refs/heads/<remotebranchname>

    Note that this pushes all commits up to and including the commit you choose. If you don’t want that to happen, you should first use git rebase -i to re-order the commits.

    Note: Picked this from thread on SO : git – pushing specific commit. Check it out for more details.

  2. I have had a similar issue when I have had to restore a site from a backup on WP Engine. What works for me is to just change something in a file.

    1. Add a return at the end of any tracked file (any change at all will do)
    2. Commit change
    3. git push to remote

    This should make sure everything matches local, adding/deleting/changing where needed, not just the last commit.

Comments are closed.