Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to list the commit's author in `git rebase -i` (interactive)?

Tags:

git

git-rebase

When I do a git rebase -i on a branch shared with a co-worker, I often want to just rebase my own commits. However, because the interactive rebase tool doesn't add the author information to the rebasing file (all t gives is the commit hash and description), I wind up having to go check commits in another tab to see if they are mine or not.

Is there any way to give git rebase -i a --format flag (or something like it), to make it include the author?

like image 385
machineghost Avatar asked Mar 07 '16 18:03

machineghost


People also ask

How do you see commits by author?

2 Answers. Show activity on this post. git log --author=<pattern> will show the commit log filtered for a particular author. ( --committer can be used for committer if the distinction is necessary).

Does git rebase change author?

You can use interactive rebase. The answer from this post gives you an example: How to change the commit author for one specific commit?. The author asks for changing author at a specific commit, but interactive rebasing can be used to change authors of multiple commits if you edit all commits that you wish to change.

What is rebase interactively in git?

Interactive rebase in Git is a tool that provides more manual control of your history revision process. When using interactive rebase, you will specify a point on your branch's history, and then you will be presented with a list of commits up until that point.

How do I list my commits?

On GitHub.com, you can access your project history by selecting the commit button from the code tab on your project. Locally, you can use git log . The git log command enables you to display a list of all of the commits on your current branch. By default, the git log command presents a lot of information all at once.


2 Answers

As of git 2.6, git rebase -i uses rebase.instructionFormat (default %s) to generate the text after pick NNNNN....

Since this is a git-config item, you can set the value per repository, for yourself in general, or even using the -c option on a one-time basis.

EDIT:

As jdknight suggested in the comments, the specific command for this would be:

git config --add rebase.instructionFormat "(%an <%ae>) %s"  

or, to avoid item repetition, as oalders suggested, you can instead set the config globally:

git config --global rebase.instructionFormat "(%an <%ae>) %s" 
like image 173
torek Avatar answered Sep 21 '22 19:09

torek


git -c "rebase.instructionFormat=(%an <%ae>) %s" rebase -i COMMIT_HASH 

Interactive output is going to look as follows:

pick b596a7b (Nik Sumeiko <[email protected]>) Refactors type checking utilities pick c8b815f (Attila Kerekes <[email protected]>) Implements commit message linting 
like image 25
Nik Sumeiko Avatar answered Sep 18 '22 19:09

Nik Sumeiko