简体   繁体   English

如何从分支获取所有提交并放入单个提交

[英]How can get all commits from branch and put in single commit

I have this 我有这个

A-----1'--2'--3'--4'  (master)
 \
  \
   D-----1--2--3--4--5--6--7--8--9 (dev)

what i want get all chnages from D - 9 since diverge from master and then put all in one commit and make new branch dev2 which will have all chnages from dev branch 我想要的是从D - 9获取所有更改,因为它们与master背离,然后全部提交并创建新分支dev2 ,它将拥有来自dev分支的所有更改

There are 30 commits in there 那里有30个提交

If you already created dev2 from master branch: 如果您已经从master分支创建了dev2

A-----1'--2'--3'--4'  (master, dev2)
 \
  \
   D-----1--2--3--4--5--6--7--8--9 (dev)

Then you can get all commits from dev branch into one commit to dev2 by: 然后,您可以通过以下方式将所有提交从dev分支提交到dev2

git checkout dev2
git merge dev --squash

Now the commit history will be (commit M is the merge commit which contains all the changes from dev branch): 现在的提交历史将是(commit M是合并提交,其中包含来自dev分支的所有更改):

              (master)
                  |
A-----1'--2'--3'--4'---M (dev2)
 \
  \                          
   D-----1--2--3--4--5--6--7--8--9 (dev)

1.从主节点创建分支dev2。获取最新的dev 3.结帐dev2 4.将dev合并到dev2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何通过Git中的其他推送提交对特定分支进行单个提交? - How can I make a single commit of specific branch from other pushed commits in Git? 如何将所有提交从特定提交移到新分支 - how to move all commits from a particular commit to new branch 如何将所有先前的提交合并为一个提交? - How to merge all previous commits into a single commit? 如何将多个提交合并到另一个分支作为单个压缩提交? - How can I merge multiple commits onto another branch as a single squashed commit? 将功能分支的所有提交放在主分支之上 - Put all commits from feature branch on top of master branch 从另一个分支复制单个提交,没有新的提交 - Copy a single commit from another branch, with no new commits 如何使用 SmartGIT 在一次提交中压缩合并从分支到主控的多个提交? - How to squash merge multiple commits from branch to master in a single commit using SmartGIT? Git:如何将两次提交之间的所有提交压缩成一次提交 - Git: How to squash all commits between two commits into a single commit 一个提交到另一个分支后如何进行所有提交? - How to make all commits after one commit into another branch? 如何在合并提交中显示功能分支的所有单独提交? - How to show all the individual commits of a feature branch in the merge commit?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM