GIT:使2个修订成为一个修订,而不是2个修订

时间:2019-06-04 20:21:45

标签: git github

enter image description here,这是我来自Github的Git远程存储库:

                                           origin/#2-ignore-pod-directory
                                          /
First commit - [origin/#1 add base project]

更多细节,我希望“首次提交”和“源/#1添加基础项目”成为“单个修订”,而不是2个修订(例如使修订的内容“源/#1添加基础项目”成为“项目的根版本”)

                              origin/#2-ignore-pod-directory
                            /
[origin/#1 add base project]

我正在使用Macbook和Source Tree应用程序。 请帮帮我!

1 个答案:

答案 0 :(得分:2)

基于评论:

git checkout B --detach # we go to B, disconnect from branch for the time being
git reset --soft HEAD~1 # set HEAD pointer to our parent revision, content remains the same, changes between B and its parent are on index ready to be committed
git commit -m "single revision that is the content of B"
# if you like how it looks like now, let's replay history between B and whatever branch is on top of it:
git cherry-pick B..some-branch
# at this point you should be able to set the pointer to the other branch on this revision
git branch -f some-branch HEAD
git checkout some-branch