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:
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.
精彩评论