Read more

Git: In an (interactive) rebase, find out which commit you are currently working on (until version < 1.7.9.5)

Arne Hartherz
December 11, 2012Software engineer at makandra GmbH

The following stopped working with git version 1.7.9.5 or higher

When you are using git rebase and are currently editing a commit (due to a conflict, for example), you may want to know the current commit. [1]\
Luckily, there is lots of useful stuff in the .git directory.

Commit hash that you are currently applying

cat .git/rebase-merge/stopped-sha
Illustration money motivation

Opscomplete powered by makandra brand

Save money by migrating from AWS to our fully managed hosting in Germany.

  • Trusted by over 100 customers
  • Ready to use with Ruby, Node.js, PHP
  • Proactive management by operations experts
Read more Show archive.org snapshot

Useful if you want to inspect the original commit for its changes, for example like:

git show `cat .git/rebase-merge/stopped-sha`

Current commit's message

cat .git/rebase-merge/message

In case you forgot what the changes are supposed to do.

Remaining rebase task list

cat .git/rebase-merge/git-rebase-todo

All commits that will be applied after the current one (and their "strategy", e.g. pick, squash, ...)

Hash of the target commit/branch that your (entire) rebase is applied to

cat .git/rebase-merge/onto

Handy when you want to look at that branch's state of the file.


[1] While git shows the commit when stopping at conflicts, for example, that information may have scrolled off your terminal's buffer or you might be working in another terminal. Or maybe you are just too lazy to scroll up.

Posted by Arne Hartherz to makandra dev (2012-12-11 11:54)