开发者

Git: delete a single remote revision

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 开发者_Go百科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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜