0

We have a master branch from which we periodically branch out ("cut") release branches. All the release branches are guaranteed to have the prefix release/.

Suppose that at some time in the past we cut release branch release1. A few commits are added to master and now we want to cut release branch release2.

Is there a way to retrieve the list of commits between those cuts? There might have been arbitrarily many commits, so simply doing a git log -10 to get the 10 latest commits will not quite do. I also don't have any guarantees about when exactly the last cut was made. I don't know if it happened yesterday, last hour, last year...

5
  • It would be better to not invent terminology, which confuses things. You're just describing branches (which are just commit pointers) and commits, and you seem to be asking about work done between two commits. Commented Nov 6, 2023 at 15:44
  • What I do when I “cut” a release is that I merge it into master (or the main branch) again when I’m done. Commented Nov 7, 2023 at 9:53
  • I think it mostly has to do with non-standard terminology that I used, but it's often from the angriest people that you get the best responses, so ¯\_(ツ)_/¯ Commented Nov 7, 2023 at 15:49
  • 1
    Making up terminology does make it harder, both for you to look stuff up in the documentation, and for others to parse, and to identify possible duplicates. Learning what things are called and reading the documentation are key steps of learning to use any moderately complex tool. Commented Nov 7, 2023 at 16:34
  • 1
    I'm not debating that at all; I have learned from the comments and from the issue and will do better in the future. Commented Nov 7, 2023 at 20:12

3 Answers 3

2

Firstly, you should tag your branch points. It'll make life much easier in the future.

Secondly, "cut" isn't git terminology - you're not making a master for producing vinyl LPs. You're creating release branches, right? This operation is called branching.

Anyway, if you want to find the last common ancestor of your current master and a given release branch (which will be the branch point you ought to have tagged)

$ git merge-base master release1

will tell you. The list of commits is just

$ git rev-list master ^$(git merge-base master release1)

or whatever

Sign up to request clarification or add additional context in comments.

Comments

0

Read up on limiting commits from git log.

Use --since and --until:

git log --since "t1" --until t2"

The date format are quite flexible, words like yesterday are also taken.

One example:

git log --since "2023-11-06" --until "2023-12-06"

1 Comment

Ah, unfortunately this assumes that I know a priori what t1 and t2 are. I actually don't. Sorry if the question was confusing. I will edit it to reflect this.
0

We are quite fortunate to be mechanically creating release branches through a dedicated Jenkins job that makes them in the format release/yyMMdd-HHmmss. Consequently:

$ git fetch
$ LAST_RELEASE=`git branch -a | grep -E origin/release/[0-9]{6}-[0-9]{6} | sort | tail -1
$ git log $LAST_RELEASE..master

does the trick.

2 Comments

I adhered to both of your comments. Thank you for them.
if you don't want to assume anything about the order in which the release branches were created: git log master --not $(git branch --format="%(refname:short)" --list origin/release/*)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.