1

Git does not store branch history, since a branch is just a kind moving label on a commit history.

But it is important for me to see whether certain code changes were pushed to master on a certain date. (The server got code on that date.)

What's the idiomatic way to do this?

Joshua Fox
  • 18,704
  • 23
  • 87
  • 147
  • 1
    *[...] a branch is just a moving tag [...]* No. Careful; "branch" and "tag" have refer to distinct Git concepts. You also write: *[...] it is important for me to see whether certain code changes were pushed to master on a certain date*. If some commit is of historical importance, mark it with a tag, not with a branch. See http://stackoverflow.com/a/25874607/2541573 – jub0bs Jul 02 '15 at 08:36
  • Thank you, I edited the text accordingly. – Joshua Fox Jul 02 '15 at 13:30

1 Answers1

3

In general, you can't do this, by design. You can tell if a commit is on a branch, and you can tell when the commit was created, but you aren't necessarily going to be able to answer the question that you want to.

There are alternatives however, which may be of use.

  1. Use a git merge --no-ff when merging onto the master branch. That will create a merge node even if it's unnecessary from a DAG perspective. You can then encode in the git message that it's a merge to master, and that becomes your point of truth for later analysis.
  2. Use the git reflog to find out what the state of master was at any time. The reflog is normally time limited to 90 days, but that's tunable through the gc.reflogExpire option. You may want to disable explicit calls to this if you have access to the local repository.
  3. Use a different mechanism to trace your requirements. It seems that you want to know what master was on a given date so that you can determine what code was pushed on a given date. But there's going to be a difference between when code was pushed and when it was installed, unless you've got an automated pushing mechanism - in which case, use that to create your infinite log of requirements. Alternatively, the automated push should create an annotated tag, which allows you to verify what was pushed when and can include additional metadata such as the person who initiated the operation.
AlBlue
  • 23,254
  • 14
  • 71
  • 91
  • Thank you. This is a good answer. I am still puzzled as to why a VCS can't answer a simple question like "Was bugfix X in the master code base on March 11, 2015," but if that's how it is, we'll use these approaches. – Joshua Fox Jul 02 '15 at 13:32