LoPoBo
LoPoBo

Reputation: 1847

How to find changes of a file across all branches in a Git repository?

In a Git repository I'm working with we have one main branch and several feature branches which different teams are working with. In some cases I would like to know if anybody else is working with a specified file/directory. Is there a way to check this in Git, without having to manually run the check for each feature branch?

Another way to put it is that I want to find out if my modifications to a specific file/directory can create merge conflicts with any other branch.

So technically I think I would like to know if there are any commits which contains changes to a specific file/folder and that are reachable from any ref (e.g. a feature branch) but not reachable from a specific rev (e.g. the main branch).

Desired output would be branch names and/or commit hashes.

Upvotes: 1

Views: 594

Answers (1)

Romain Valeri
Romain Valeri

Reputation: 22057

git log --all ^master -- path/to/directory/*

would produce a commit list of everything that has impacted said directory but is yet unknown to master.


Then, to map that with branches, you can check specific commits to know where they're already present with

git branch -a --contains <commitHash>

It'll output every branch having this commit in its history.

Upvotes: 1

Related Questions