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

后端 未结 7 533
说谎
说谎 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:46

    You can also check how such detection is done in __git_ps1 function in contrib/completion/git-prompt.sh, which can be used for git-aware bash prompt:

                    if [ -f "$g/rebase-merge/interactive" ]; then
                            r="|REBASE-i"
                            b="$(cat "$g/rebase-merge/head-name")"
                    elif [ -d "$g/rebase-merge" ]; then
                            r="|REBASE-m"
                            b="$(cat "$g/rebase-merge/head-name")"
                    else
                            if [ -d "$g/rebase-apply" ]; then
                                    if [ -f "$g/rebase-apply/rebasing" ]; then
                                            r="|REBASE"
                                    elif [ -f "$g/rebase-apply/applying" ]; then
                                            r="|AM"
                                    else
                                            r="|AM/REBASE"
                                    fi
                            fi
                    fi
    

提交回复
热议问题