How can I see how much I have remaining of a rebase?
Asked Answered
H

6

37

How can I see how much work is left on a rebase while it's in progress?

I.e. I want to see how much work git has left to check.

Haar answered 8/10, 2015 at 19:11 Comment(3)
This doesn't sound related to conflicts, it sounds like the OP wants to know what step is currently being executed.Todd
@EdwardThomson You are correct, sir.Haar
@jubobs, when the rebase makes a lot of progress, it shows a counter such as (10/35), so it must be possible, the information existsOverdone
M
27

Starting with git version 2.26

Here's the shell command that prints the rebase progress:

( RMD="$( git rev-parse --git-path 'rebase-merge/' )" && N=$( cat "${RMD}msgnum" ) && L=$( cat "${RMD}end" ) && echo "${N} / ${L}" ; )

Sample output will be like

4 / 7

You can modify the last echo command parameter to print it using the format you like.

For git with versions that are <= 2.25

( RaD="$( git rev-parse --git-path 'rebase-apply/' )" && N=$( cat "${RaD}next" ) && L=$( cat "${RaD}last" ) && echo "${N} / ${L}" ; )
Milagro answered 31/7, 2019 at 13:32 Comment(4)
Just a note: those commands will only work on Linux. Might be useful to also just list the directories as well.Youthen
@MattVukomanovic , I am not quite sure what exactly you mean by "only work on Linux". It works in GNU+Linux, macOS and windows. It works perfectly in ZSH and Bash. I do use ZSH in Cygwin. And Bash as shell that comes with "Git for Windows".Milagro
ah I don't use git bash on windows I use cmd.exe with the linux tools included in the system folder, so that is the confusion.Youthen
@MattVukomanovic, I also don't quite use Bash for Windows. At least not the shell itself. I do use Cygwin (yes, its a little bit slow :( ) which is much better than anything else in windows as for me.Milagro
Y
21

You are probably looking for this information for a normal rebase instead of an interactive rebase.

That information isn't shown for non interactive rebases. However you can find it out by looking in your rebase-apply directory.

In that directory there is all the information you need. Specifically if you are running with the default .git directory location you can find it out by running these commands

cat .git/rebase-apply/next
cat .git/rebase-apply/last

If you want to know the commit which is currently being applied then you can use the following

cat .git/rebase-apply/original-commit

And if you want to see the actual patches which are being applied then you can look at the numbered files in .git/rebase-apply

Youthen answered 1/5, 2017 at 2:55 Comment(1)
Starting with version 2.26 of git the git rebase $Onto $Branch command now triggers interactive rebase by default. This answer is not valid for that case anymore. Please see my answer here - https://mcmap.net/q/416256/-how-can-i-see-how-much-i-have-remaining-of-a-rebase for a proper solution.Milagro
L
4

If you're using git-prompt.sh, your prompt will show something like |REBASE-i (x/y) when resolving a conflict during an interactive rebase, where x is rebase step out of y where the conflict occurred.

Lorgnon answered 10/10, 2015 at 17:1 Comment(0)
N
1

I think you are looking for

git rebase --edit-todo
Novitiate answered 26/2, 2023 at 2:38 Comment(0)
J
1

git status

Example content:

On branch xxx
Your branch and 'origin/xxx' have diverged,
and have 4 and 7 different commits each, respectively.
  (use "git pull" if you want to integrate the remote branch with yours)

No commands done.
Next commands to do (5 remaining commands):
   pick d33eb3d Add 3ds not performed case -
   edit c58cad6 Refactor extract method to update models
  (use "git rebase --edit-todo" to view and edit)
You are currently editing a commit while rebasing branch 'xxx' on '18cc67c'.
  (use "git commit --amend" to amend the current commit)
  (use "git rebase --continue" once you are satisfied with your changes)

nothing to commit, working tree clean
Jackstay answered 7/12, 2023 at 11:59 Comment(1)
This solved my instance of this question - thanks!Festoonery
D
0

If you just want to take a look at it and you're using Bash, you can run: __git_ps1. It will display something similar to (feature/avarias|MERGING)(base), but concerning rebase. This string is meant to compose your prompt by assigning it to variable PS1.

Diaeresis answered 7/6, 2021 at 18:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.