I am new to Gitlab. We work on local branches in GIT and then push the changes before it get's merged to Master.
So I was trying to rollback a commit. But I somehow messed up and ended up bringing my colleagues commit's into my local branch.
Now I am trying to go back to previous version in Gitlab.
If you see the attached image, I am currently in the latest version but I want to go back to version 9. Is there anyway I can do this ?
On GitLab Web UI itself, the revert operation is documented here
The alternative would be to locally reset your branch to HEAD~
and force push, which can work if you are the only one using this branch.
But reverting is safer, and only add a new commit (instead of overriding the recent branch history). That new commit will cancel the changes done in the commit you are reverting.
I also encountered same situation, where I wanted a way to revert to some commit, specially when I am unable to perform git reset
.
I tested it on a little test project (nginx + index.html) just to see if I could revert the content of index.html to a previous version (commit). you can proceed to git repo of the project -> CI/CD -> Jobs
then pressed 🔄 button of the "build" and "deploy" stages associated with my desired commit, & it worked i.e. the content was reverted to that commit.
note that in the attached img the 🔄 signs are disappeared after I've run the jobs again,
a4b3a0a4
was my initial commit, whereas2f4d780e
was the latter.
Hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With