Basic version revert


I have committed and pushed three versions of file a. “git log” looks like this [1].

How to make my file a to be empty again? (first commit).


commit eaecfb37bc2fc804620718d9ee932ffeed63faed (HEAD → main, origin/main)
Author: ****
Date: Thu Apr 25 22:03:04 2024 +0100

commit dd0dbb7401750c808633c2e94bd55c1c517489aa
Author: <****>
Date: Thu Apr 25 21:51:00 2024 +0100
non-empty a

commit c196237f1972c0ca9c9586e8d5ff0c3e579596a9
Author: <****>
Date: Thu Apr 25 21:50:36 2024 +0100
empty a


This is not related to GitLab, but to git itself. Please refer to the official docs.

If you just want to checkout the earlier version, you can do:

git checkout c196237f1972c0ca9c9586e8d5ff0c3e579596a9

If you want to completely erase the history on this branch, I guess you could do:

git reset --hard HEAD~2
git push -f


Hi Paula, unfortunately that did not work, error attached.
But thanks for the effort I’ll check in another forum.