Git:删除单个远程修订 [英] Git: delete a single remote revision

查看:125
本文介绍了Git:删除单个远程修订的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始将我的私有Subversion项目切换到git(Github)并将代码发布给公众。因此,我是一个git新手。



不幸的是,对包含机密数据的项目进行了修订。修订没有被标记,我只知道它的哈希值。



有没有办法从远程git仓库中彻底清除特定的修订版本?
这是一个独立的项目,所以没有人会受到操作伤害。

该帖子位于这里解决了我的问题。


如果您想要修复的提交不是最新提交的内容:


  1. git rebase --interactive $ parent_of_flawed_commit



    如果您想修复几个有缺陷的提交,通过它们中最老的一个的父代。

  2. 编辑会出现,并列出所有提交的列表。


    1. 更改挑选编辑在任何您想要修复的提交之前。

    2. 保存后,git将重播列出的提交。

    3. Git会回退到你说你想编辑的每一次提交的shell:


      1. 以任何您喜欢的方式更改提交。
      2. git commit --amend
      3. git rebase --continue


    这个序列的大部分将随着各种命令的输出向您解释。这很容易,你不需要记住它 - 只要记住 git rebase --interactive 可以让你纠正提交,不管它们多久以前。



I've started switching my private subversion projects to git (Github) and release the code to the public. Therefore, I am a git newbie.

Unfortunately, there is a revision of a project that contains confidential data. The revision is not tagged, I just know its hash value.

Is there a way to completely erase that particular revision from the remote git repository? It is a solo project, so nobody will be harmed from the operation.

解决方案

The post located here solved my problem.

If the commit you want to fix isn’t the most recent one:

  1. git rebase --interactive $parent_of_flawed_commit

    If you want to fix several flawed commits, pass the parent of the oldest one of them.

  2. An editor will come up, with a list of all commits since the one you gave.

    1. Change pick to edit in front of any commits you want to fix.
    2. Once you save, git will replay the listed commits.

  3. Git will drop back to the shell for every commit you said you want to edit:

    1. Change the commit in any way you like.
    2. git commit --amend
    3. git rebase --continue

Most of this sequence will be explained to you by the output of the various commands as you go. It’s very easy, you don’t need to memorise it – just remember that git rebase --interactive lets you correct commits no matter how long ago they were.

这篇关于Git:删除单个远程修订的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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