Push only some commits to another git repository
I have two remote origin
and another
repositories and, for example, commits history on origin:master
repo:
A - B - C - D - E - F
another
is empty repo.
Need to push only last two commits E - F
to another:master
ie:
origin:master: A - B - C - D - E - F
another:master: E - F
How I can do that with possibility after to push in this two remotes without rebase or something else?
You would need a git history with an initial empty commit and two branches: one (your current master
) pointing to F
and another one pointing to the empty commit.
Check out the branch pointing to the empty commit, cherry-pick
E
and F
, and push this branch to your another
remote. As you make changes that you want in the another
repository, you'll simply cherry-pick
them over.
So, after having created the initial commit:
git checkout -b another-branch <<SHA of empty initial commit>>
git cherry-pick <<SHA of E>>
git cherry-pick <<SHA of F>>
git push another another-branch
链接地址: http://www.djcxy.com/p/49824.html
上一篇: 如何在推送提交之前将分支重置为该状态
下一篇: 只将一些提交推送到另一个git存储库