Search code examples
gitgit-log

How do I list the time stamp and commit message for git comits made this year?


I have a git history with multiple branches with some unmerged. I would like to extract a log of each comit forward from a single past comit to today.

I have had a look at Git Log but havent found a function which just gives me everything. I have just set a tag on the branch to set the starting point.

I would like the history to have the timestamp, comit message and branch.


Solution

  • git log --all --since="1 year ago" --author-date-order --pretty=format:'%at %s' > year.log
    

    could be a base for what you need, to be tweaked if need be.


    About the "branch" part : in short, you can't.

    A bit more precisely, branches are mere pointers to track useful places in a repo tree, but they're ultimately disposable, while commits are not, they're the real matter of your history tree.

    When a commit is made, many information enter its creation, but branches aren't part of that at all. What is relevant to git is the question "Is that commit reachable from this branch?".

    By the way, you can commit with a detached HEAD state. If you do, what branch does this commit "belong" to? And if you go on commiting, and you later create a branch on the tip of your commit series, how could git retroactively write that branch information in now-immutable commits which are now "on" this branch?