How to know if there is a git rebase in progress?

后端 未结 7 537
说谎
说谎 2020-12-02 18:02

When I start a git rebase -i, I can issue commands like git rebase --continue, or git rebase --abort. Those commands only work if a re

7条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-02 18:31

    From a bash command line:

    ls `git rev-parse --git-dir` | grep rebase
    

    That will return exit code 0 (success) if there is a rebase folder, and it will output the rebase folder to STDOUT. If you are not in the middle of a rebase, then it will output nothing and return non-0 exit code. So you could even do something like this:

    ls `git rev-parse --git-dir` | grep rebase || echo no rebase
    

提交回复
热议问题