如何从gitlab中完全删除提交? [英] How to completely remove a commit from gitlab?

查看:3469
本文介绍了如何从gitlab中完全删除提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在git repo中提交了一个提交,并推送了它,但是不小心它包含了我们生产机器的一些密码。所以我删除了提交:

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

这确实从提交列表中删除了提交,但是gitlab上的提交网址仍然显示了



我不确定这是git还是将提交内容保存在gitlab服务器上,还是gitlab数据库以某种方式存储了内容



有人知道一种完全删除提交及其内容的方法吗?



p>

解决方案

您可能应该首先查看GitLab存储库的Web界面。如果分支存在,则可以通过运行

  git push< remote>将其删除。 :<分支> 

这将用< branch> 替换在指定的远端,冒号之前是什么,即什么也没有。
如果您不能使用Web界面检查分支是否位于远程,则应该能够获取所有分支,或者至少使用某些 git fetch 之类的命令,不确定如何操作。



如果该分支未在远程服务器上列出,则您只拥有远程服务器上的本地副本,并且您应该能够使用例如

  git branch -D< remote> /< branch>删除该副本。 

我不能代表GitLab的内部,所以我不能保证数据将被销毁如果这样做,则应按照建议的方式替换所有密码。


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?

解决方案

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.

这篇关于如何从gitlab中完全删除提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆