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 rebase is in progress.
How can I know if there is a rebase in progress?
(I would greatly appreciate some details on how rebase works internally; what does git do to a repo that gives it the "rebase in progress" status,?)
If you have EasyGit,
eg status
will tell you:In a colored terminal, the notification is very prominent:
(
eg help topic middle-of-rebase
displays the documentation “How to resolve or abort an incomplete rebase”.)You can also check how such detection is done in
__git_ps1
function incontrib/completion/git-prompt.sh
, which can be used for git-aware bash prompt:I am using this command
is_rebase=$(git status | grep "rebasing" | wc -l)
For one thing, there is a
ORIG_HEAD
in place during a rebase (but that is not limited to the rebase command)But you can also look at the 2010 Git 1.7.0
git-rebase.sh
script itself (which is as "internal" as you can get ;) ).Lines like those can give you another clue:
sabgenton comments:
rebase-apply
seems to appear withrebase
,rebase-merge
shows up only with withrebase -i
.And hippy also comments, in 2017, that:
Jelaby suggests in the comments:
That is because the
git rev-parse --git-path <path>
: does resolve "$GIT_DIR/<path>
".Git 2.6+ (Q3 2015) will print more information during a rebase:
See commit 592e412, commit 84e6fb9 (06 Jul 2015), commit 84e6fb9 (06 Jul 2015), and commit df25e94, commit 05eb563 (30 Jun 2015) by Guillaume Pagès (
gitster
).(Merged by Junio C Hamano --
gitster
-- in commit 178d2c7, 03 Aug 2015)If there’s an interactive rebase in progress, this will tell you where you are in the process:
Right now I’m editing the “ktio” patch in an interactive rebase.
If there’s no rebase going on, it will look like this:
From a bash command line:
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: