Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (29.3k points)

Is there a way to determine when a Git branch was created? I have a branch in my repo and I don't remember creating it and thought maybe seeing the creation timestamp would jog my memory.

2 Answers

0 votes
by (50.2k points)

For this, you could Use

git show --summary `git merge-base foo master`

If you’d like to achieve this using gitk, then use

gitk --all --select-commit=`git merge-base foo master`

(where foo is the name of the branch you are looking for.)

This is the way to determine when a git branch was created.

0 votes
by (2.8k points)

Git cannot directly provide the precise branch creation date, but there are some ways to work around it so that it can be predicted more or less when it was born. 

Here are a few suggestions:

Find the Date of the First Commit on the Branch

git log --reverse --pretty=format:"%h %ad %s" --date=local <branch-name>

Git’s reflog keeps records of the operations on the local repository that include branch checkouts, and branch creations.

git reflog show <branch-name>

In case your branch was pushed to GitHub, you can get the date of the first push to the remote and that will be the timestamp you are looking for. This is not the exact time of creation, but it gives the relevant hint as well if the branch was pushed soon after its creation.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...