We saw how to undo the merge requests in GitLab.
Let's also see how to delete the objects in GitLab.
The history in Git is a nice feature as Git keeps all the changes
about your files maintained in a history tree.
You can delete the files from a Git repository and they are removed from the
user interface, but they remain in the Git history. For some teams that is not
useful or is unnecessary, but for enterprise projects,
keeping the files in the history with the author of the file is
very important. In this demonstration, we will create a commit
where we delete a file from the project.
Go to any project where you have a few files.
Let's open the Dockerfile in our project. For our course,
this is not a useful file because we are not exploring
Docker, so let's remove this file.
You can remove the files right from the user interface. Click on the
Delete button, and you can create a commit to delete the file and make
the changes in the master branch. Click on the Delete file button to
create a commit and push the changes.
The file is now deleted. In the GitLab user interface, you
will not find the file in the latest changes.
If you clone the project, the first time a user accesses the project,
they would not see the file.
Let's go back to the main page of the project.
We can still access the file in the history.
If you go to the Commits under Repository,
you can access the history of this project.
The commit that deletes the file is this latest one.
The file exists in the commits before this.
For example, if we open the commit that is second on the top,
we can access the file.
Let's browse the commit and access the file there. On this page, you have
the Dockerfile in this commit. Completely deleting the files from Git
history is very difficult and often not useful because rewriting the
history removes a lot of useful information,
such as the author details and who made the changes,
etc.