Welcome to the Treehouse Community
Looking to learn something new?
Alex Flores7,864 Points
Starting from a previous commit (Git)
I have a couple questions regarding using Git with WordPress.
Is it possible to go back to a previous commit and then start again from there. Basically re-writing all commits that took place after it? I figured I could go back to a previous commit and then branch from there and then merge my branch back in with the Master. Is there a better way?
While using WordPress, say I want to branch off and try something new that I just want to test. So I create a new branch and make the changes I wanted to test. How do I actually access the backend or even the front end of my localhost site? When I checkout to a previous commit and then go to the website, it says, "The theme directory "THEME NAME" does not exist.".
Any help would be much appreciated. Thanks guys/gals!
For your first query you're looking for git reset.
As for the second, if you've both created a new branch and switched to it then it should work fine:
git branch branchname git checkout branchname
Or in one step:
git checkout -b branchname
Of course if some of your code is referencing some files that you've deleted in the branch, then it won't work, since switching branches will delete any files that don't exist in the branch (unless they are set to being ignored in your
Sue Dough35,800 Points
One thing I want to mention:
You can checkout any commit any time:
Press q to quit once you find a commit ID you want to select
Then simply run
git checkout 58bf307669d7799dbd4107398d72abc36615e772
This will allow you to go back in history on any commit.
Git reset can also be very helpful but sometimes you don't want to reset and simply want to see something from a bit ago.