Dmi*_*kin 3 git git-rebase git-commit git-cherry-pick
我想从我的currentrepo 中的特定提交添加一些特定的更改到我的upstreamrepo。
运行这样的东西:
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
Run Code Online (Sandbox Code Playgroud)
还写入所有以前的更改。
我只想将该提交的特定更改写入upstreamrepo,因此它不包括我的currentrepo 中先前提交所做的更改,这些更改不在upstream.
有很多关于在计算器上的信息的cherry-pick和rebase,但没有回答这个非常具体的问题。
您可以在上游仓库的远程分支之外创建本地分支,然后选择。
假设“上游”是您的上游遥控器的名称,您可以执行以下操作:
git fetch upstream
git checkout -b new-branch upstream/<upstream branch>
git cherry-pick <commit hash>
git push upstream new-branch
Run Code Online (Sandbox Code Playgroud)
您可以使用检查上游存储库的名称
git remote -v
Run Code Online (Sandbox Code Playgroud)