![](/img/trans.png)
[英]how to git cherry-pick commit declaring our history contains it
[英]Git: How to cherry-pick a commit without all previous history
我想将我current
库中特定提交的一些特定更改添加到我的upstream
库。
运行如下: git push upstream <commit SHA>:<remotebranchname>
添加提交加上所有以前的更改
运行类似
git checkout -b new-branch
git pull <remote> <upstream branch> branch is
git cherry-pick <commit hash>
git push <remote> new-branch
还写入所有以前的更改。
我只想将该提交的特定更改写入upstream
库,因此它不包括我current
库中先前提交所做的更改,这些更改不在upstream
。
StackOverflow 上有很多关于cherry-pick
和rebase
但没有一个能回答这个非常具体的问题。
您可以在上游仓库的远程分支之外创建本地分支,然后选择。
假设“上游”是您的上游遥控器的名称,您可以执行以下操作:
git fetch upstream
git checkout -b new-branch upstream/<upstream branch>
git cherry-pick <commit hash>
git push upstream new-branch
您可以使用检查上游存储库的名称
git remote -v
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.