git: How to automate interactive rebase / replace it by equivalent git commands

前端 未结 2 1032
孤街浪徒
孤街浪徒 2020-12-17 23:50

I need to automate a interactive rebase or replace it by other commands. Just let me explain my current situation:

In an svn->git transition i need to rebase the new

2条回答
  •  -上瘾入骨i
    2020-12-18 00:14

    expect might help you, too. Though this isn't quite what you need to do, you should be able to use something similar to automate your process:

    #!/usr/bin/env expect
    spawn git rebase -i HEAD~2
    
    # change the second "pick" to "squash"
    # jump to top (if not there), down, delete word, insert 's' (for squash), Escape, save and quit
    send "ggjdwis \033:wq\r"
    
    expect "# This is a"
    
    # skip past first commit message (assumed to be one line), delete rest of file
    # down 4, delete 3 lines, save and quit
    send "4j3d:wq\r"
    
    interact
    

提交回复
热议问题