繁体   English   中英

Git,为所有分支编辑根提交

[英]Git, edit root commit for all branches

我必须重写存储库的历史记录,因为它包含一些凭据。 由于必须修改root提交,因此我遵循了Git Faq的指示:

git rebase -i允许您方便地编辑除根提交以外的所有以前的提交。 以下命令显示如何手动执行此操作。

 # tag the old root git tag root `git rev-list HEAD | tail -1` git checkout -b new-root root # edit... git commit --amend # check out the previous branch git checkout @{-1} # replace old root with amended version git rebase --onto new-root root # cleanup git branch -d new-root git tag -d root 

我的问题是,尽管我在存储库中已经有两个分支和几个标签,但我希望重写历史记录以将其应用于这些对象。 回购尚未公开,所以这不是问题。 我之前曾问过类似的问题 ,但在这种情况下,不使用git rebase命令。 这是我的仓库的基本图表:

+  master branch
|
|   + topic branch
|   |
|   |
+---+
|
|
|
+  TAG
|
+  Initial commit, the commit I'd like to amend for all branches

可能吗

使用git filter-branch代替git-rebase。

如果您真的真的觉得rebase会更好,使用现代git可以使用--root选项来git-rebase。 或者,如果您有没有此选项的较旧git,则可以选择root提交,然后在其基础上重新构建。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM