gpt4 book ai didi

Git:删除单个远程修订

转载 作者:太空狗 更新时间:2023-10-29 13:14:56 25 4
gpt4 key购买 nike

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

不幸的是,有一个包含 secret 数据的项目修订版。修订版没有标记,我只知道它的哈希值。

有没有办法从远程 git 存储库中完全删除该特定修订版?这是一个单独的项目,因此没有人会因操作而受到伤害。

最佳答案

帖子位于here解决了我的问题。

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:删除单个远程修订,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2261031/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com