zoukankan      html  css  js  c++  java
  • git rebase 合并提交

    git log
    

    现在可以看到有3个提交:
    change 1.mp4 size to small //修改后未超大小的文件
    add 1.mp4 big //超大小的文件
    add 1.mp4 //未超大小的文件

    commit 0b265673698e336557c781286dbc89bc89f2193f (HEAD -> master)
    Author: kingBook <412126604@qq.com>
    Date:   Fri Apr 27 11:19:10 2018 +0800
    
        change 1.mp4 size to small
    
    commit 1441e74583ff80e4c65b01174cbfa39f45c9e811
    Author: kingBook <412126604@qq.com>
    Date:   Fri Apr 27 10:41:53 2018 +0800
    
        add 1.mp4 big
    
    commit 8ae0ddd75875a030122aa36ab7cd7c97c6c1c8ee (origin/master)
    Author: kingBook <412126604@qq.com>
    Date:   Fri Apr 27 10:39:46 2018 +0800
    
        add 1.mp4
    

    输入:wq退出,回到命令行
    现在要把”add 1.mp4 big“这个提交合并到其它的提交,否则无法推送到远程仓库。
    执行:

    git rebase -i HEAD~3
    

    可以看到最近3次提交的信息窗口:

    pick 8ae0ddd add 1.mp4
    pick 1441e74 add 1.mp4 big
    pick 0b26567 change 1.mp4 size to small
    //以下省略
    

    现在我们把"add 1.mp4 big"与"change 1.mp4 size to small"合并
    1、把它们前面的pick改为s。

    pick 8ae0ddd add 1.mp4
    s 1441e74 add 1.mp4 big
    s 0b26567 change 1.mp4 size to small
    //以下省略
    

    2、然后ctrl+c退出编辑模式,再输入:wq回到命令行,执行git log输出如下:

    # This is a combination of 3 commits.
    # This is the 1st commit message:
    
    add 1.mp4
    
    # This is the commit message #2:
    
    add 1.mp4 big
    
    # This is the commit message #3:
    
    change 1.mp4 size to small
    ...
    

    3、要求你输入修改提交信息,"#"注释将会忽略,也可以忽略这一步,直接输入:wq回到命令行,。

    git add -A
    git rebase --continue
    

    之后就可以正常提交了

  • 相关阅读:
    大二下第十三周学习笔记
    对C++多态的一次小分析
    vs2015中用汇编(转)
    挖个坑
    ListCtrl
    获得进程完整路径的第二种方法
    The Meeting Place Cannot Be Changed(二分+eps精度)
    CodeForces 494A
    Anya and Ghosts CodeForces
    寒假给自己立个flag
  • 原文地址:https://www.cnblogs.com/kingBook/p/8961762.html
Copyright © 2011-2022 走看看