Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rollback to previous version in Gitlab

Tags:

git

github

gitlab

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 ?

GitLab

like image 432
Rishabh Jain Avatar asked Sep 20 '25 11:09

Rishabh Jain


2 Answers

On GitLab Web UI itself, the revert operation is documented here

https://docs.gitlab.com/ee/user/project/merge_requests/img/cherry_pick_changes_commit.png

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.

like image 157
VonC Avatar answered Sep 23 '25 08:09

VonC


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, whereas 2f4d780e was the latter.

Hope it helps.

screenshot of gitlab jobs page

like image 28
Amir Rahimpour Avatar answered Sep 23 '25 08:09

Amir Rahimpour