Git:如何在没有以前所有历史的情况下挑选承诺

时间:2019-11-27 11:54:06

标签: git git-commit git-rebase git-cherry-pick

我想从我的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存储库中先前提交所做的更改,而这些更改不在{ {1}}。

关于Stack upstreamcherry-pick的信息很多,但没有一个回答这个非常具体的问题。

1 个答案:

答案 0 :(得分:2)

您可以在上游回购中的远程分支之外创建本地分支,然后进行樱桃选择。

假设“上游”是上游遥控器的名称,则可以执行以下操作:

<div aria-expanded='true'>has <em>aria-expanded</em> which equals "true"</div>
<div aria-expanded='false'>has <em>aria-expanded</em> which equals "false"</div>
<div>does not have <em>aria-expanded</em> attribute</div>

您可以使用以下方法检查上游仓库的名称

git fetch upstream
git checkout -b new-branch upstream/<upstream branch>
git cherry-pick <commit hash>
git push upstream new-branch
相关问题