zoukankan      html  css  js  c++  java
  • git 重写历史

    • 重写最后一次提交的commit
       git commit --amend
    • 修改多个历史
      git rebase -i HEAD~3

      命令执行后结果如下:

      复制代码
      pick f7f3f6d changed my name a bit
      pick 310154e updated README formatting and added blame
      pick a5f4a0d added cat-file
      
      # Rebase 710f0f8..a5f4a0d onto 710f0f8
      #
      # Commands:
      #  p, pick = use commit
      #  e, edit = use commit, but stop for amending
      #  s, squash = use commit, but meld into previous commit
      #
      # If you remove a line here THAT COMMIT WILL BE LOST.
      # However, if you remove everything, the rebase will be aborted.
      #
      复制代码

      将你想修改的每一次提交前面的pick改为edit

      edit f7f3f6d changed my name a bit
      pick 310154e updated README formatting and added blame
      pick a5f4a0d added cat-file

      当你保存并退出编辑器,Git会倒回至列表中的最后一次提交,然后把你送到命令行中,同时显示以下信息:

      复制代码
      $ git rebase -i HEAD~3
      Stopped at 7482e0d... updated the gemspec to hopefully work better
      You can amend the commit now, with
      
             git commit --amend
      
      Once you’re satisfied with your changes, run
      
             git rebase --continue
      复制代码

      然后

      $ git commit --amend

      $ git rebase --continue

      ok一切搞定。

    参照资料地址:http://git-scm.com/book/zh/ch6-4.html

     
     
  • 相关阅读:
    RAID-磁盘阵列
    Redis-Cluster 5.0.4 集群部署
    linux系统磁盘缩容
    MongoDB Replica Set 集群
    CentOS7 GlusterFS文件系统部署
    CentOS7 firewalld防火墙规则
    centos7 升级openssh到openssh-8.0p1版本
    MySQL 中操作excel表格总结
    超哥带你学GIT
    学习是主动吃苦
  • 原文地址:https://www.cnblogs.com/mliudong/p/4184178.html
Copyright © 2011-2022 走看看