Is there a way to determine when a Git branch was created? I have a branch in my repo and and I don't remember creating it and thought maybe seeing the creation timestamp would jog my memory.
相关问题
- Why does recursive submodule update from github fa
- Extended message for commit via Visual Studio Code
- Emacs shell: save commit message
- Can I organize Git submodules in a flat hierarchy?
- Upload file > 25 MB on Github
相关文章
- 请教Git如何克隆本地库?
- GitHub:Enterprise post-receive hook
- Git Clone Fails: Server Certificate Verification F
- SSIS solution on GIT?
- Is there a version control system abstraction for
- ssh: Could not resolve hostname git: Name or servi
- Cannot commit changes with gitextensions
- git: retry if http request failed
Pro Git § 3.1 Git Branching - What a Branch Is has a good explanation of what a git branch really is
Since a branch is just a lightweight pointer, git has no explicit notion of its history or creation date. "But hang on," I hear you say, "of course git knows my branch history!" Well, sort of.
If you run either of the following:
you will see what looks like the "history of your branch", but is really a list of commits reachable from 'branch' that are not reachable from master. This gives you the information you want, but if and only if you have never merged 'branch' back to master, and have never merged master into 'branch' since you created it. If you have merged, then this history of differences will collapse.
Fortunately the reflog often contains the information you want, as explained in various other answers here. Use this:
to show the history of the branch. The last entry in this list is (probably) the point at which you created the branch.
If the branch has been deleted then 'branch' is no longer a valid git identifier, but you can use this instead, which may find what you want:
Or in a Windows cmd shell:
Note that reflog won't work effectively on remote branches, only ones you have worked on locally.
As ponted out in the comments and in Jackub's answer, as long as your branch is younger than the number of days set in the config setting
gc.reflogexpire
(the default is 90 days), then you can utilize your reflog to find out when a branch reference was first created.Note that
git reflog
can take mostgit log
flags. Further note that theHEAD@{0}
style selectors are effectively notions of time and, in fact, are handled (in a hacked sort of way) as date strings. This means that you can use the flag--date=local
and get output like this:It may also be useful at times to use
--date=relative
:One last note: the
--all
flag (which is really a git-log flag understood by git-reflog) will show the reflogs for all known refs inrefs/
(instead of simply,HEAD
) which will show you branch events clearly:Use
If you’d rather see it in context, then use
(where foo is the name of the branch you are looking for.)
This is something that I came up with before I found this thread.
I'm not sure of the git command for it yet, but I think you can find them in the reflogs.
My files appear to have a unix timestamp in them.
Update: There appears to be an option to use the reflog history instead of the commit history when printing the logs:
You can follow this log as well, back to when you created the branch.
git log
is showing the date of the commit, though, not the date when you made the action that made an entry in the reflog. I haven't found that yet except by looking in the actual reflog in the path above.Use:
to show all the living cycle of your repository in current folder. The branch name that first appear (from down to up) is the source that was created.
That mean:
Branch development is created (checkout -b) from master
Branch feature-jira35 is created (checkout -b) from development
Branch feature-jira-sut-46 is created (checkout -b) from development