赞
踩
我们开发需求的时候,开发分支可能会有多个commit信息,等合并到主分支master的时候,会造成commit累赘,下面这种方法就能解决这个问题
test02
,有 2 条 commit
记录,git log
查看:➜ git:(test02) git log -2
commit 6f53d8d8d4d570082e580554b68d36707f50421d
Author: 流星
Date: Mon Feb 13 16:45:21 2023 +0800
chore: 修改登录功能
commit 832f3e68516de9162d0f03bc23bdbb6f86297b9d
Author: 流星
Date: Mon Feb 13 15:51:27 2023 +0800
feat: 添加登录功能
(END)
test01
上去➜ git:(test02) git checkout test01
Switched to branch 'test01'
merge
分支时,添加一个--squash
字段➜ git:(test01) git merge test02 --squash
Updating b1d603ed0..d950712fc
Fast-forward
Squash commit -- not updating HEAD
packages/pages/src/table/index.vue | 1 +
1 file changed, 1 insertion(+)
➜ git:(test01) ✗ git status
On branch test01
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: packages/pages/src/table/index.vue
➜ git:(test01) ✗ git commit -m 'feat: 添加登录功能'
→ No staged files match any configured task.
✔ Preparing lint-staged...
✔ Running tasks for staged files...
✔ Applying modifications from tasks...
✔ Cleaning up temporary files...
--------------------- git add ------------------
Nothing specified, nothing added.
hint: Maybe you wanted to say 'git add .'?
hint: Turn this message off by running
hint: "git config advice.addEmptyPathspec false"
---------------------- done --------------------
[lstest01 832f3e685] feat: 添加登录功能
1 file changed, 1 insertion(+)
test01
分支就没有test02
分支那么多累赘的commit
注释了➜ git:(test01) git log
commit 832f3e68516de9162d0f03bc23bdbb6f86297b9d (HEAD -> test01)
Author: 流星
Date: Mon Feb 13 15:51:27 2023 +0800
feat: 添加登录功能
(END)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。