0

I am working on a huge repo with a lot of branches in it. Most of them are already merged to master and some of them are waiting to be merged.

The need is for me to see which of them are touching into a specific directory.

For example, in this repo there are several APIs, let's say A, B, C, etc. I would like to see which of the branches of this repo are trying to change A. That's why I mentioned a 'specific directory' above, but if there is an easier way to check, it's also acceptable.

I am not sure which way would be convenient to do that? Choosing to develop a script or are there any git native commands?

1 Answer 1

2

(This is not a complete answer. Just trying to bring some elements to the conversation.)

For a given branch, it would be quite trivial with something like

git rev-list --count <referenceBranch>..<featureBranch> -- path/to/directory/*

which would ouput a positive value only if the branch has touched the given directory since last reference state.


Now to loop over branches and execute the above test, I first thought about for-each-ref which, as names indicates, cycles through each ref in a given refset (here it would be refs/heads), but I don't yet see how to make these work together. probably just a loop in bash?

Interesting question indeed.

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

2 Comments

Thanks! This is indeed quite a progress for me and makes total sense what you are thinking but I am not sure if I can make them work together also:)
Thanks, I used this snippet to create a bash script that runs tasks (like build) only in the given monorepo directories that had changes.

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.