How to completely remove a commit from gitlab?

旧街凉风 提交于 2020-05-12 20:33:06

问题


I made a commit in my git repo and pushed it, but accidentally it contained some passwords for our production machines. So I deleted the commit:

git reset --hard HEAD~1
git push --force

That indeed removed the commit from the list of commits, but the url to the commit on gitlab still shows the source of the commit.

I'm not sure whether this is git which still saves the contents of the commit on the gitlab servers, or the gitlab databases which somehow store the contents of the commit, but I really need to completely remove that commit from the gitlab servers.

Does anybody know a way to completely remove a commit and it's contents from gitlab?


回答1:


You should probably start with looking at the web interface for your GitLab repository. If the branch is there, you can delete it by running

git push <remote> :<branch>

This will replace <branch> with what's before the colon, i.e., nothing, at the specified remote. If you can't check if the branch is at the remote using the web interface, you should be able to get all the branches or at least list them using some git fetch like command, not sure how.

If the branch is not listed at the remote, you just have a local copy of what was at the remote, and you should be able to delete that copy with e.g,

git branch -D <remote>/<branch>

I can't speak for GitLab's internals, so I can't guarantee that the data will be destroyed if you do this, so you should replace all passwords as already suggested.



来源:https://stackoverflow.com/questions/49648127/how-to-completely-remove-a-commit-from-gitlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!