git:将两个请求合并为一个请求

摘要:
Gitrebase ihEAD~2解释:此命令可以以文本形式显示您提交的两次请求。如果数字2被4替换,则您最近四次提交的信息将显示如下:1 pick56a06efchange1:删除一个空白行2 pickedbeab5change2:addlogonMainActivity34#Rebase23198ba..Edbeab5onto23198ba5#6#命令:7#p,pick<commit>=usecommit8#r,reword=使用commit,但编辑命令sage 9#e,edit=使用commmit,但停止修改10#s,squash=使用提交,但删除上一个命令11#f,fixup=类似于“squash”,但放弃此命令的日志消息12#x,exec=运行命令using shell13#b,break=停止此处14#d,drop˂commit=删除命令15#l,label=标签当前HEAD,标签16#t,重置=resetHEAD标签17#m,merge[-C|-C][#]18#。使用原始mergecommit的19#消息创建一个commit。使用-C保存commit消息。21#22#可订购该系列;他们是从上到下执行的。23#24#如果您的运动在这里进行,请点击THATCOMMITWILLBELOST。25#26#然而,如果你把所有东西都拿走了,你的基地就会被摧毁。27#28#注意contentcommittee建议为out3.将第二行中的pick更改为s或f。

1.为什么需要将两次提交的请求合并为一个请求进行提交?

1.审核代码时候,更加方便一些。

2.多次的提交可能只是为了修复一个bug。

3.更加方便别人为你审阅代码信息。

2.怎么才能将两次请求合并为一个请求进行提交?

1.使用git命令,可以看到如下的文本信息。

git rebase -i HEAD~2

解释:该命令可以将你两次提交的请求在以文本的形式进行展示

如果数字2换成4,那么将展示你最近的4次提交信息

如下文本所示:

  1 pick 56a06ef change 1: remove one blank line
  2 pick edbeab5 change 2: add log on MainActivity
  3 
  4 # Rebase 23198ba..edbeab5 onto 23198ba (2 commands)
  5 #
  6 # Commands:
  7 # p, pick <commit> = use commit
  8 # r, reword <commit> = use commit, but edit the commit message
  9 # e, edit <commit> = use commit, but stop for amending
 10 # s, squash <commit> = use commit, but meld into previous commit
 11 # f, fixup <commit> = like "squash", but discard this commit's log message
 12 # x, exec <command> = run command (the rest of the line) using shell
 13 # b, break = stop here (continue rebase later with 'git rebase --continue')
 14 # d, drop <commit> = remove commit
 15 # l, label <label> = label current HEAD with a name
 16 # t, reset <label> = reset HEAD to a label
 17 # m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]
 18 # .       create a merge commit using the original merge commit's
 19 # .       message (or the oneline, if no original merge commit was
 20 # .       specified). Use -c <commit> to reword the commit message.
 21 #
 22 # These lines can be re-ordered; they are executed from top to bottom.
 23 #
 24 # If you remove a line here THAT COMMIT WILL BE LOST.
 25 #
 26 # However, if you remove everything, the rebase will be aborted.
 27 #
 28 # Note that empty commits are commented out

3.将第二行的pick 修改成s或者f。如果修改为s,那么你之前进行的提交不会消失,如果是f的话,那么你之前进行的提交信息,都会消失。

  1 pick 56a06ef change 1: remove one blank line
  2 s edbeab5 change 2: add log on MainActivity
  3 
  4 # Rebase 23198ba..edbeab5 onto 23198ba (2 commands)
  5 #
  6 # Commands:
  7 # p, pick <commit> = use commit
  8 # r, reword <commit> = use commit, but edit the commit message
  9 # e, edit <commit> = use commit, but stop for amending
 10 # s, squash <commit> = use commit, but meld into previous commit
 11 # f, fixup <commit> = like "squash", but discard this commit's log message
 12 # x, exec <command> = run command (the rest of the line) using shell
 13 # b, break = stop here (continue rebase later with 'git rebase --continue')
 14 # d, drop <commit> = remove commit
 15 # l, label <label> = label current HEAD with a name
 16 # t, reset <label> = reset HEAD to a label
 17 # m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]
 18 # .       create a merge commit using the original merge commit's
 19 # .       message (or the oneline, if no original merge commit was
 20 # .       specified). Use -c <commit> to reword the commit message.
 21 #
 22 # These lines can be re-ordered; they are executed from top to bottom.
 23 #
 24 # If you remove a line here THAT COMMIT WILL BE LOST.
 25 #
 26 # However, if you remove everything, the rebase will be aborted.
 27 #
 28 # Note that empty commits are commented out

注意:这里的文本编辑操作不做详细描述,不会的可以查看linux下的基本命令。

4.保存退出后,push代码:git push  -f (注意:因为时rebase操作,所以要加-f, 强制push), 推送完成, 如下所以,完成将两个提交合并为一个。

免责声明:文章转载自《git:将两个请求合并为一个请求》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇您的硬件设置已被更改,请重新启动计算机,使更改生效iOS开发(Swift):创建UINavigationView的三种方法下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

Beyond Compare脚本:命令行批量比较文件并生成html格式的差异报告

BComp.exe /silent /closescript /solo @E:compareTestBCbatch.txt text-report layout:side-by-side options:display-all,line-numbers title:"report" output-to:"E:compareTest eport.htm"...

python数据分析——pandas的拼接操作

pandas的拼接操作 pandas的拼接分为两种: 级联:pd.concat, pd.append 合并:pd.merge, pd.join 1. 使用pd.concat()级联 pandas使用pd.concat函数,与np.concatenate函数类似,只是多了一些参数: objs axis=0 keys join='outer' /...

有相同键值的json合并为一个数组

今天我们分享的是,如何使用javascript来将两个含有相同键值的json合并为一个数组。 已知arr1的长度和arr2相等,arr1和arr2含有相同的键值id,使用js如何得到merge。 如下数据: var merge= [{id: 12,name: 20,title: 500}, {id: 13,name: 30,title: 666}]; 下面...

利用Python进行数据分析-Pandas(第五部分-数据规整:聚合、合并和重塑)

  在许多应用中,数据可能分散在许多文件或数据库中,存储的形式也不利于分析。本部分关注可以聚合、合并、重塑数据的方法。 1、层次化索引   层次化索引(hierarchical indexing)是pandas的一项重要功能,它使你能在一个轴上拥有多个(两个以上)索引级别。抽象点说,它使你能以低纬度形式处理高纬度数据。我们来看一个简单的栗子:创建一个Ser...

Git敏捷开发--rebase命令

git rebase是git下比较常用的命令,以下记录自己遇到较多的使用场景。 合并分支 在多人协作的项目中,拉分支是很常见的事情,经常需要同步自己的分支与远端master分支一致,有两种方式: git merge master git rebase master 两者的区别在于:前者会在生成一条 Merge branch master into XX...

Pandas数据合并方法merge()、concat()、combine_first()方法,数据的重塑和矩阵转置等操作的实现

阅读提示 本文将提到Pandas数据合并方法merge()、concat()、combine_first()方法,数据的重塑和矩阵转置等操作的实现 目录 阅读提示 一、数据合并 1、pandas.merge() 方法 以列名为连接键 以索引作为连接键 2、pandas.concat() 方法 3、combine_first() 方法 二、数...