Skip to content
Lingfeng_Ai edited this page Jul 1, 2018 · 1 revision

1. 如何撤销pull request中无用的commit

  1. 克隆代码到本地
  2. 查看全部远端分支:git branch -a
  3. 切换到远端分支 git checkout #2 origin/\#2-Akin\'s-Laws-of-Spacecraft-Design
  4. git rebase -i <start> <end>
pick 08afee0 创建文章  #把不想要到commit删除,或者把pick改成drop  
pick f89746f 补充翻译
pick ea08769 Update Akin's Laws of Spacecraft Design
pick 2a6dae5 Rename Akin's Laws of Spacecraft Design to Akin's Laws of Spacecraft Design.md

# Rebase bc05af1..2a6dae5 onto bc05af1 (4 command(s))
#
# 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
# 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.
#
# Note that empty commits are commented out
  1. 保存退出
  2. git push --force

ps:如果你的commit包含了有用和无用的文件(不是一个良好的commit),那么你不能用上述的方法,请把无用的文件清理掉之后新建一个commit

友情链接

Clone this wiki locally