首页 > 其他 > 详细

git 重写历史

时间:2014-12-25 12:37:47      阅读:395      评论:0      收藏:0      [点我收藏+]
  • 重写最后一次提交的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

 

 
 

git 重写历史

原文:http://www.cnblogs.com/mliudong/p/4184178.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!