Git 如何合并commits成一个(squash)
- 方法一:使用git rebase
- 方法二:使用git reset
两种方法。
方法一:使用git rebase
本地先从upstream拉一个branch
git checkout -b <main_branch>
git pull upstream <main_branch>
git checkout <dev_branch>
然后git rebase
git rebase -i <main_branch>
在跳出来的vim中对于需要squash的commit 前面把pick删掉写成s即可
注:这种方法如果upstream和本地对于起始commit都有update会有conflict squash不会成功
方法二:使用git reset
先通过git log查看一下要合并到哪个commit
然后简单明了使用
git reset --soft <commit_hash_to_squash_to> && git commit
再加上commit信息然后:x保存成功即可
最后
以上就是无心柜子最近收集整理的关于Git 如何合并commits成一个(squash)的全部内容,更多相关Git内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复