Git

How to Determine When a Git Branch Was Created?

Git branches are used while communicating between the local and remote repository for multiple purposes, such as updating the remote server for other project members or downloading the updated version of the remote repository to the local machine. Developers can create multiple branches for each feature. Additionally, they are allowed to get information about the branch, for instance, when it was created. The “git log -g” command can be used for this purpose.

The outcomes of this study are:

How to Find When a Git Local Branch Was Created?

Git users can get the whole info about the created branches, such as date, time, first commit id, author name, user id, HEAD index, and many more. To do so, the “git log -g” command can be used.

Try out the following instructions to get the above-stated required info!

Step 1: Redirect to Git Root Folder

First, run the provided command to switch to the Git root folder:

$ cd "C:\Users\nazma\Git"

 
Step 2: List Local Branches

Then, run the “git branch” command to view the list of all existing local branches:

$ git branch

 

Step 3: Get Info About Created Branch

Finally, to get the info about when the existing local branches are created by utilizing the “git log” command:

$ git log -g

 
Here, the “-g” option is used for finding the first entry of branches in the repository reflog. As you can see, detailed information about all the existing local branches from when created by users is shown below:

How to Find When a Git Local Branch was Created Using Gitk Browser?

Another way to find detailed information about the local branches is by using “Gitk”. It is the graphical repository browser that is maintained as an independent Git project. To do so, the “gitk –all –select-commit=‘<particular-query>’” command can be used as follows:

$ gitk --all --select-commit=`git merge-base alpha master`

 
After executing the above-provided command, the Gitk browser will be open and you can get the needed information about the branch:


That’s all! We have provided the easiest way to determine when the Git branch was created.

Conclusion

Git users can get the whole info about the created branches, such as date, time, first commit id, author name, user id, HEAD index, and many more. To do so, the “git log -g” command can be used. Another way to get when the branch is created is the “Gitk” graphical repository browser. For this purpose, the “gitk –all –select-commit=‘commit-query’” command can be used. This blog illustrated the procedure for getting when a Git branch was created.

About the author

Maria Naz

I hold a master's degree in computer science. I am passionate about my work, exploring new technologies, learning programming languages, and I love to share my knowledge with the world.