[英]Partial subtree upstream push in Git
I have a situation in Git in which I have a core repo that is shared/used with other repos via Git subtree.我在 Git 中有一个情况,我有一个核心存储库,它通过 Git 子树与其他存储库共享/使用。 In repo "project", I have the subtree repo "core" and in that core I made various commits that I have since committed and pushed to "project".
在回购“项目”中,我有子树回购“核心”,在该核心中,我进行了各种提交,此后我已提交并推送到“项目”。 I now want to push these changes in the "core" folder to the actual "core" repo.
我现在想将“核心”文件夹中的这些更改推送到实际的“核心”存储库。 This would normally be accomplished with:
这通常可以通过以下方式完成:
git subtree push --prefix=/core/ core-repo master
However, there happens to be a single commit in the "core" folder that I would like to keep local to "project".但是,“核心”文件夹中恰好有一个提交,我想将其保留在“项目”的本地。 The cheap hacky way would be to just push everything upstream and then revert that one commit.
便宜的 hacky 方法是将所有内容推到上游,然后还原一次提交。 I was wondering if there was a more appropriate way though to stop those particular changes from ever going upstream.
我想知道是否有更合适的方法来阻止这些特定的变化向上游传播。 Thanks.
谢谢。
Usually you can push up to a specific commit with:通常,您可以通过以下方式推送特定提交:
git push <remotename> <commit SHA>:<remotebranchname>
This will push to the remote branch all commits up to the one specified (included).这会将所有提交推送到远程分支,直到指定的(包括在内)。
You should be able (but I have not tested it) to do this also with a subtree push.您也应该能够(但我尚未对其进行测试)通过子树推送来执行此操作。 Something like:
就像是:
git subtree push --prefix=/core/ core-repo <commit SHA>:master
In your case <commit SHA>
should be the commit preceding the one you want to avoid to push.在您的情况下,
<commit SHA>
应该是您想要避免推送的提交之前的提交。
Notice that, if you have commits that follow the one you do not want to push, you will have to reorder commits using git rebase
.请注意,如果您在不想推送的提交之后有提交,则必须使用
git rebase
重新排序提交。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.