search

Home  >  Q&A  >  body text

git 删除中间的 commit

维护一个 git 项目, 发现里面的 commit 描述都是,修改某某文件,增加某某文件,有没有办法把这些 commit 删除呢?

比方说:
1 代表的是有效的 commit ,注释清楚
0 代表注释不清晰的 commit

1 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1

我要如何把注释不清楚的 commit 删掉呢?

过去多啦不再A梦过去多啦不再A梦2770 days ago589

reply all(2)I'll reply

  • 怪我咯

    怪我咯2017-05-02 09:21:49

    The main question is not "delete", but "merge".

    1. git rebase -i <commit hash>Start from a certain commit
    2. In the open editor, place pick 修改为 squash before the commits that need to be merged
    3. Save and exit

    Suggestion git checkout -b squash_some_commits Create a temporary branch to handle this matter. If you make a mistake, delete it and start over.

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-05-02 09:21:49

    git rebase 命令
    http://zhidao.baidu.com/link?url=Q8DXAl3eVJpkBKF9hcmCi0TlKC0Vyu47PuIkfBWviAoACV6wk67ahzJDXPgxsTpJtyz5euQzqTVu_95QAnN9xLazCzMPsC9gBwFT3RifXYO

    reply
    0
  • Cancelreply