Intro#
So now I need to revert my changes back to a working state.
Enabling time travel#
To make this even possible I have setup my own OneDev git services. This service keeps track of every new addition and mistake I make. OneDev also has more features that sets up this website when I release a new post, read more about my OneDev git setup in a future post.
Git is a very powerful tool and it can do many many things. But for my mistakes the easiest solution is to just revert everything I did and basically move back one commit to the past. I have (currently) simple setup with no branches and only work in main.
Process#
Identify the problem#
I made a commit without properly testing my blog and it broke my page. My thought process was that Hugo is building the static pages after every change completely. Next time I will read the manual before blindly deleting files (said no one ever).
So after removing the folder and adding it to the .gitignore the page did not work anymore and returned 404s.
Clearly my last commit broke things, so lets travel back in time and agree that it never happened.
find the commit#
We’re having a look at the last commits. Later we will need the hash to make git move back.
git log -n 5 --oneline
Move into your project directory and have a look:
[bjarne ~]$cd /opt/hugo/knet
[bjarne knet]$ git log -n 5 --oneline
0eb2276 (HEAD -> main, origin/main, origin/HEAD) removed public and added ignore
1b096b2 manual knet: 2025-05-17 23:05:33
0bd9849 manual knet: 2025-05-17 22:34:43
22eb167 manual knet: 2025-05-17 22:33:23
9287ce6 Initial
Move back in time#
In my case 0eb2276 is the broken commit and 1b096b2 is the last good commit.
Now I’m saying that I want to move one commit before the current one:
git push origin +0eb2276^:main
+ means it is a non-fastforward commit
^ means I want to move one commit behind the one I mention
in the main branch
and I want to push all of that to my server
I can use origin because on this device I created the directory by git clone
You can see your remotes by using
git remote -v
in my case:
origin https://git.kohnkenet.de/knet/ (fetch)
origin https://git.kohnkenet.de/knet/ (push)
OneDev#
I can see these changes in the WebUI. Navigate to your project and then to Code > Commits.
Here you can see the commits before the rollback:
And here after I pushed:
Now I can write this article and push it to the server:
