ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Github PR 时合并多次提交的 commits All In One

2022-07-08 13:03:57  阅读:257  来源: 互联网

标签:PR git -- commits rebase Github 提交 commit


Github PR 时合并多次提交的 commits All In One

git commit -s

GitHub 会帮你把新增的 commits 全部追加到一个未合并 PR 里去(PR 会自动更新)

git add <files>
git commit -s -m "some description here"
git push origin feat-xxx

PR 前合并多个 Commits, 方便 code review ✅

# 通过 rebase 命令来完成 2个/多个 commits 的合并
$ git rebase -i HEAD~2 
# $ git rebase -i HEAD~n 

# vim 编辑,把最后面的一条/多条 commit 的 `pick`  改成 `s` 
`pick` 9b7d63b docs: just for test => `s` 9b7d63b docs: just for test

#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending

# s, squash = use commit, but meld into previous commit 
# s: 使用该 commit, 但是要把它合并到前面一条 commit 中去 ✅

# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
# d, drop = remove commit
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.

修改过去的提交记录

# 如果指定提交之后再次指定提交,就会显示提交清单。
# 请在清单里找出要修改的提交,将该行的 “pick” 改成 “edit”,之后保存并退出。
$ git rebase -i <commit>

# 接着,编辑要修改的文件,保存文件之后指定--amend选项,以执行提交。
$ git commit --amend

# 最后,指定--continue选项以执行rebase。
$ git rebase --continue

https://backlog.com/git-tutorial/cn/reference/log.html#sec3

refs

https://www.cnblogs.com/daniel-hutao/p/open-a-pr-in-github.html#六我提交了一个-pr然后遇到了问题-abcdefg

https://backlog.com/git-tutorial/cn/


Flag Counter

©xgqfrms 2012-2020

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载

标签:PR,git,--,commits,rebase,Github,提交,commit
来源: https://www.cnblogs.com/xgqfrms/p/16457911.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有