Search git reflog

Viewed 4468

I create a new branch when a new issue pops up. These branches are named starting issu. After merging with master these branches are deleted. I wanted to get a list of all such branches. I was able to get it using git reflog

>git reflog
55e8b45 (HEAD -> master, origin/master, origin/HEAD) HEAD@{0}: merge issu4-HasScript-and-HasFormat-checkbox-toggle: Fast-forward
7caf2c6 HEAD@{1}: checkout: moving from issu4-HasScript-and-HasFormat-checkbox-toggle to master
55e8b45 (HEAD -> master, origin/master, origin/HEAD) HEAD@{2}: commit (amend): Column validation including Has-Script and Has-Format
490a29a HEAD@{3}: commit: Column validatio inclnsuding Has Script and Has Format
7caf2c6 HEAD@{4}: checkout: moving from master to issu4-HasScript-and-HasFormat-checkbox-toggle
7caf2c6 HEAD@{5}: merge issu3-make-SFTPFingerprint-required: Fast-forward
fbad7cd HEAD@{6}: checkout: moving from issu3-make-SFTPFingerprint-required to master
...

Is there any way to filter these entries to get all merges starting with issu.

I am trying to get all deleted branches that were merged into the master and started with issu. Other solutions that get these are also fine.

I searched a lot and could not find a solution.

Update:

I am using windows. The solution that i currently have is

git reflog | findstr /c:"merge issu"

Is there any solution in git itself?

2 Answers

You can use this command,

git reflog --grep-reflog=<pattern>

In your case it would be, git reflog --grep-reflog="merge issu"

Link

If you are on Linux, grep is the tool for this job, along with pipes which allow you to take the output from one command as the input for another command. In this case, you can do

git reflog | grep issu

For more info, type man grep for the grep documentation.

Note: In all Windows flavors, you can use Git Bash to do this. In Windows 10, you can use the Linux subsystem.

Related