• 一步
    2018-12-15
    git rebase -i 开始commit [结束commit], 在执行这个命令时,
    如果没有指定 结束commit,那么结束commit 默认为当前分支最新的 commit,那么rebase 结束后会自动更新当前分支指向的 commit,
    如果指定了结束 commit,而且结束 commit不是当前分支最新的 commit,那么rebase 后会有生成一个 游离的 head,,而且当前分支指向的commit 不会更新

    作者回复: 👍

     1
     9
  • Washington
    2018-12-15
    老师您好,如果想撤销这次合并,应该怎么做呢?

    作者回复: 你指不想要本地刚merge出来的commit,对吗?如果工作区、暂存区和HEAD一起回答merge前,执行 git reset --hard HEAD^ 就行啦

    
     2
  • Spring
    2019-02-09
    合并commit时,常规语法是:git rebase -i 父节点commitID,如果前面没有父节点怎么写呢?

    作者回复: 好问题。命令行没法写出来(因为自己本身已经是最根的那个commit了),当交互命令回车后,会出现设置界面,我们不妨自己手工把最根部的那个commit添加进来,并配置好对应的策略。

    
     1
  • 隆
    2018-12-14
    老师讲的非常好! 项目用到gerrit ,能讲讲gerrit吗?比如用git 来对gerrit上change rebase 合并处理。谢谢!

    作者回复: 其实原理搞懂了,哪种代码平台一点就通了。我到时候看看,把github,gitlab和gerrit三个平台merge的方式做个比较好了

    
     1
  • Altruiste
    2019-10-19
    老师,这个合并commit背景是什么,是这几个commit提交到远程自己的分支后的场景吗
    
    
  • 杨陆伟
    2019-08-14
    合并后会导致一些commit就没有用了,git会不会清理?

    作者回复: git会清理的

    
    
  • 君莫惜
    2019-06-30
    合并前四个commit message

    1. git rebase -i 第五个commitID

    2. 将前四个commit message前的pick改为 s,保存

    3. 在新的页面最前面输入我们新的commit message
    展开

    作者回复: 👍

     1
    
  • 孙杏
    2019-03-21
    遇到一个不懂的问题,希望老师解答一下。
    首先是git rebase -i commitid 执行之后,把窗口关了,再次进来使用git是下面这个情况
    su@sun-PC MINGW64 /e/learninggit/git_learning (master|REBASE-i 1/2)
    然后使用git rebase --abort命令,报错如下
    su@sun-PC MINGW64 /e/learninggit/git_learning (|REBASE-m)
    $ git rebase --abort
    error: could not read '.git/rebase-merge/head-name': No such file or directory
    这种情况下还需要怎么改呢,还能恢复吗
    展开

    作者回复: https://stackoverflow.com/questions/3685001/git-how-to-fix-corrupted-interactive-rebase

    如果安装里面不同人的方法都搞不定的话,git reset --hard 先回到rebase前,然后再试试看吧。

    
    
  • Neverland
    2018-12-31
    请问下老师,
    我在执行完git rebase指令后,出现下面提示的错误,按照提示执行git rebase --continue 之后,可以成功合并4个commit。但不太理解为什么会出这个错误?以及错误提示中提到的git rebase --continue 和git rebase --edit-todo是什么意思。

    谢谢

    coexs-MBP:git_learning coex$ git rebase -i 80766daa0ba0a150a
    [detached HEAD 46caa3d] Create a complete web page adding index and logo Adding style Adding js
     Date: Wed Dec 19 22:00:31 2018 -0800
     4 files changed, 132 insertions(+)
     create mode 100755 images/git-logo.png
     create mode 100755 index.html
     create mode 100755 js/script.js
     create mode 100755 styles/style.css
    error: Your local changes to the following files would be overwritten by merge:
        readme
    Please commit your changes or stash them before you merge.
    Aborting
    hint: Could not execute the todo command
    hint:
    hint: pick 800f537f1c5a760c779af586ed3534dc9cfbfaaf Moving filename readme to readme.md
    hint:
    hint: It has been rescheduled; To edit the command before continuing, please
    hint: edit the todo list first:
    hint:
    hint: git rebase --edit-todo
    hint: git rebase --continue
    Could not apply 800f537... Moving filename readme to readme.md
    coexs-MBP:git_learning coex$ git rebase --continue
    Successfully rebased and updated refs/heads/master.
    展开
    
    
  • DriveMan_邱佳源
    2018-12-27
    老师
    Administrator@PC-DriveMan MINGW64 ~/git/learning (master|REBASE-i 6/6)
    后面为什么会有REBASE-i 6/6 怎么解决的呢。我已经git reset回退到以前的commit,还是没有办法解决

    作者回复: 不好意思,没看懂问题的描述

    
    
  • DriveMan_邱佳源
    2018-12-27
    老师,合并出现的问题如下:
    Administrator@PC-DriveMan MINGW64 ~/git/learning (master|REBASE-i)
    $ git rebase -i 2fb364994b6
    fatal: It seems that there is already a rebase-merge directory, and
    I wonder if you are in the middle of another rebase. If that is the
    case, please try
            git rebase (--continue | --abort | --skip)
    If that is not the case, please
            rm -fr ".git/rebase-merge"
    and run me again. I am stopping in case you still have something
    valuable there.


    Administrator@PC-DriveMan MINGW64 ~/git/learning (master|REBASE-i)
    $ git rebase --skip
    Auto-merging index.html
    CONFLICT (add/add): Merge conflict in index.html
    error: could not apply b030c3a... Add index.html
    Resolve all conflicts manually, mark them as resolved with
    "git add/rm <conflicted_files>", then run "git rebase --continue".
    You can instead skip this commit: run "git rebase --skip".
    To abort and get back to the state before "git rebase", run "git rebase --abort".
    Could not apply b030c3a... Add index.html

    Administrator@PC-DriveMan MINGW64 ~/git/learning (master|REBASE-i 1/6)
    $ gitk
    git rebase --continue

    sdaf
    git rebase -i
    git rebase -i 2fb364994b6d9820

    后面我不管输入什么 好像都没有效果,不知怎么解决
    展开

    作者回复: 你先 git rebase --abort 退出前一个未执行完毕的rebase,然后重新再来。

    
    
  • DriveMan_邱佳源
    2018-12-21
    请问下老师,合并连续的commit message出现的问题如下,是什么原因呢?
    You asked to amend the most recent commit, but doing so would make
    it empty. You can repeat your command with --allow-empty, or you can
    remove the commit entirely with "git reset HEAD^".
    interactive rebase in progress; onto 15b6f27
    Last commands done (4 commands done):
       squash db93f64 修改Readme名称
       squash f15cbd4 modific readme name
    No commands remaining.
    You are currently rebasing branch 'master' on '15b6f27'.

    No changes
    Could not apply f15cbd4... modific readme name
    展开

    作者回复: 两个用来squash的commit合并后,最后的内容与前面一个commit没发生任何变化,git提示你,如果还是坚持生成commit的话,那就加上参数 --allow-empty,否则用reset。

    
    
  • 时间杀手
    2018-12-20
    我使用git reset --hard HEAD^ 命令撤销合并commit操作,结果是合并提交没有了,也没有恢复到之前的多次提交

    作者回复: 哦,明白你的意思啦,你在练习squash(合并)的时候,不妨给合并前的HEAD对应两个分支,一个用来做rebase -i的操作,另一个分支拿来做恢复之前的commit用。

    这样能听明白吗?

    
    
  • 李噶星
    2018-12-15
    老师演示了将4个commit合并成了一个,那如果有一个分支是从其中的一个commit分出去的,合并完成后,之前的分支会怎么样呢?

    作者回复: 好问题,可以实践一下。我估摸着从那个有分叉的commit及之前的commit都会保留的,即使其他分支做了合并。

    
    
我们在线,来聊聊吧