Posted on
How to Get your Drupal 8 site Back to Where You Were Before a Composer Update Broke it - using Git

We've all been there, the last composer update you did has broken your whole Drupal 8 website and now you need to unravel the mess and put everything back to how it was.

So, how do you get back to where you were? Well, if you are using Git (and you certainly should be using some sort of version control) and the changes you made are not yet committed you can do this

# reset back to your last commit - should give you the commit number
> git reset --hard

If you have commited changes, you can reset back to a particular commit:

# reset back to a specific commit - using the commit number
> git reset --hard xxxxxxx

Nope, still not working...

You would imagine that this would have fixed all your issues and given you back a functioning site, but this can still leave a broken installation - because it doesn't delete new files and folders. So next, we need to delete those new files and directories:

# test the command before running it for real
> git clean -n

# do it!
> git clean -f

#To remove directories

> git clean -f -d or git clean -fd

Drupal 8 Restored

So, now, you should have everything exactly as it was before whatever you did broke things. All ready to break it again, reset back to where you were - and break it again until you figure out which bit isn't working.

Pretty basic - but very useful - stuff!

Tags

Add new comment

Request a Free Quotation

Your Name