git使用笔记

删除最后一次提交

  1. 查看提交历史
$ git log --oneline
d4417e7 (HEAD -> master) third
911f088 second
32500fa first
  1. 删除
  • 使用git rebase -i HEAD^删除
  1 pick d4417e7 third # 将pick改为drop, 然后保存                                                                                                                                                                 
  2 
  3 # Rebase 911f088..d4417e7 onto 911f088 (1 command)
  4 #
  5 # Commands:
  6 # p, pick <commit> = use commit
  7 # r, reword <commit> = use commit, but edit the commit message
  8 # e, edit <commit> = use commit, but stop for amending
  9 # s, squash <commit> = use commit, but meld into previous commit
 10 # f, fixup <commit> = like "squash", but discard this commit's log message
 11 # x, exec <command> = run command (the rest of the line) using shell
 12 # b, break = stop here (continue rebase later with 'git rebase --continue')
 13 # d, drop <commit> = remove commit
 14 # l, label <label> = label current HEAD with a name
 15 # t, reset <label> = reset HEAD to a label
 16 # m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]
 17 # .       create a merge commit using the original merge commit's
 18 # .       message (or the oneline, if no original merge commit was 
 19 # .       specified). Use -c <commit> to reword the commit message.
 20 #
 21 # These lines can be re-ordered; they are executed from top to bottom.
 22 #
 23 # If you remove a line here THAT COMMIT WILL BE LOST.
 24 #
 25 # However, if you remove everything, the rebase will be aborted.
 26 #
 27 # Note that empty commits are commented out 
~                                                 
  • 使用git reset --hard HEAD^

查看日志

  1. git log --oneline --decorate
  2. git log stat
  3. git log stat -p

参考

Learning Git Branching

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值