Git

Find out a Git Branch Creator

In Git, a branch is a pointer to a particular/certain commit in Git history. Developers create and deal with multiple branches while working on a development project. When a user creates a branch, Git stores its date, time, creator name, and other information. Sometimes, users may need to find out the creator of the particular Git branch. In this situation, Git commands are available to find out the creator’s information about the Git branches.

This article will explain the method of finding out the creator of branches in Git.

How to Find out the Branch Creator in Git?

To find out the creator of the Git branch, the “git for-each-ref” command is used with the “–format” option to specify the formats for getting the desired output:

git for-each-ref --format='%(authorname) %09 -%(refname)' | sort

 

Here:

  • for-each-ref” command searches all Git branches.
  • authorname” is used to show the author of the branch or tags.
  • refname” is utilized to display all the references including branches and tags.

In the below output, the creator of local and remote branches can be seen:

Moreover, if a user wants to find out the branch date and time also, the “comitterdate” format can be specified in the same command:

git for-each-ref --format='%(committerdate) %09 %(authorname) %09 %(refname)' --sort=committerdate

 

That was all about finding out the Git branch creator.

Conclusion

To find out the creator of Git branches, the “git for-each-ref –format=’%(authorname) %09 -%(refname)’ | sort” command can be used. This command will search for all Git branches and display the creator’s name along with the branch name. This article explained the procedure of finding out the creator of branches in Git.

About the author

Laiba Younas

I have done bachelors in Computer Science. Being passionate about learning new technologies, I am interested in exploring different programming languages and sharing my experience with the world.