gpt4 book ai didi

git - 如何在不添加到孤儿历史的情况下将主分支的更改 merge 到孤儿分支?

转载 作者:太空狗 更新时间:2023-10-29 13:55:04 24 4
gpt4 key购买 nike

我有一个用于我的博士论文的 git 存储库(在 latex 中)。大学政策不允许我与我的研究导师分享我论文的背景审查章节,我可以自由分享其他章节并征求意见。

为了与我的顾问共享存储库,我创建了一个孤立分支 (noRevBranch),删除了所需的章节,并将该分支推送并跟踪到 github 上的一个新存储库。我可以与他分享这个,他无法访问已删除的章节,因为这里没有历史记录。

问题是如何将我在未来对 master 分支所做的任何更改 merge 到 noRevBranch,而不会将 master 分支历史附加到新的 merge 提交?

最佳答案

您现在可以保留该结构。
你可以做的是使用 git cherry-pick <range of commits>将所有新提交提交到“孤立”分支。

git cherry-pick <SHA-1>...<SHA-1>

Apply the change introduced by the commit at the tip of the master branch and create a new commit(s) with this change.

... 的语法是一个提交范围。抓取从开始(排除)到最后一次的所有提交。

enter image description here


读出完整 git cherry-pick documentation for all the options you can use

关于git - 如何在不添加到孤儿历史的情况下将主分支的更改 merge 到孤儿分支?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36677857/

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