Question

There are multiple guys working on a git repository and all of them have write access to it. Someone by mistake has created random branches on the repo. How can we know who is the owner of these branches ?

Is there a way to identify the following things:

  1. Who created a particular branch ?
  2. When was the branch created ?
Was it helpful?

Solution

A 'branch' in git is only a label. All the info git knows is the name and a git hash.

From that follows you can not ask git for that info. You might be able to figure it out form the content (author or committer of pathces), or a text file with description.

In my repos there is a file repo_info.txt that describes the content, rules on commit, branching policy, etc.

OTHER TIPS

This will depend on how that shared repository is managed.

If it's being accessed as just a directory (either locally to all the developers or using a network file system such as NFS or SMB) or is being accessed over ssh with each developer using their own system-level account (rather than a shared git account) you may be able to determine that by looking at the file-system information about the branch pointer. This would be a file named after the branch under refs/heads for a bare repository or under .git/refs/heads for a non-bare repository. But branches which haven't been updated for awhile may have been converted to packed refs which would lose that information.

If you're using gitolite to access the repository, the logs that it maintains would have information about all updates (including the first update which created them) to branches including the user and time.

In other cases you may be out of luck, unless software that you're using keeps track of that information. git itself does not attempt to track that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top