Git:删除单个远程修订 [英] Git: delete a single remote revision
问题描述
我已经开始将我的私有Subversion项目切换到git(Github)并将代码发布给公众。因此,我是一个git新手。
不幸的是,对包含机密数据的项目进行了修订。修订没有被标记,我只知道它的哈希值。
有没有办法从远程git仓库中彻底清除特定的修订版本?
这是一个独立的项目,所以没有人会受到操作伤害。
如果您想要修复的提交不是最新提交的内容:
- 编辑会出现,并列出所有提交的列表。
git rebase --interactive $ parent_of_flawed_commit
如果您想修复几个有缺陷的提交,通过它们中最老的一个的父代。
- 更改
挑选
至编辑
在任何您想要修复的提交之前。
- 保存后,git将重播列出的提交。
Git会回退到你说你想编辑的每一次提交的shell:
- 以任何您喜欢的方式更改提交。
git commit --amend $ c $
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:
git rebase --interactive $parent_of_flawed_commit
If you want to fix several flawed commits, pass the parent of the oldest one of them.
An editor will come up, with a list of all commits since the one you gave.
- Change
pick
toedit
in front of any commits you want to fix.- Once you save, git will replay the listed commits.
Git will drop back to the shell for every commit you said you want to edit:
- Change the commit in any way you like.
git commit --amend
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屋!