使用rebase -i合并多次commit

  • 使用git log查看提交commit
  • 使用git rebase -i 合并多次commit提交记录
# 命令输入:
git rebase -i 

# 命令输入后,进入另一个界面,信息如下:
pick k6187c7dbe8    add helo111  
pick s6577eb3440    add hello222  
pick h5b9508a3ab    add hello333  
pick 681ab9cc261    add hello444  
# Rebase 150a643..2fad1ae onto 150a643  
#  
# 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  
#  f, fixup = like "squash", but discard this commit's log message  
#  x, exec = run command (the rest of the line) using shell  
#  
# 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.  
#  
# Note that empty commits are commented out  

现在想把四条commit合并成一条(第一条的commit),对上面的内容做出修改:顶部的的几行中第一个单词pick为squash,表示与当前提交的父提交合并,即可修改完成

  • 若已做git rebose -i命令,但现在又不想做修改了,执行此命令以放弃此次压缩:
git rebose --abort

自此就可以愉快的push了,不会有之前那么多的commit。

你可能感兴趣的:(学习历程,Linux/Unix,Git/Github,杂说,LFS,各个发行版Linux的使用,定制版Linux半年)