Git: a list of all files with an owner / identifier on the first commit (or rather, the first user to commit the file)

How do I, using git, list all the files in a specific directory along with the owner / identifier of these files on the first commit?

It turns out that such pieces of information, as this happens in many files, are usually more complicated?

Edit: Well, git does not provide a direct way to do this, but it saves who is committing the various files, right? I need this list in a specific directory so that I can understand for which files I am responsible.

+4
source share
5 answers

Try:

$ cd thatdirectory $ git ls-files | while read fname; do echo "`git log --reverse --format="%cn" -1 $fname` first added $fname" done 

The โ€œfirst additionโ€ may be misleading in case of renaming.

+7
source

A very simple approach would be

 git rev-list --objects --all | cut -d' ' -f2- | sort -u | while read name; do git --work-tree=. log --reverse -1 --format="%cn%x09$name" -- "$name" done 

Cautions:

  • this shows the first committer name (% cn) of each path existing in the object database (not only in (any) current version)
  • the -all flag means that you want all objects to be on all branches. To limit the scope, replace it with the name of the branch / tag or just HEAD

  • n 2 performance (not scalable enough for very large repo operations)

  • incorrect output if the path contains formatting sequences (e.g.% H, etc.)

It starts with an empty name, which is the root tree.

+4
source

I happened to face a similar situation. The accepted answer works, but why don't you guys use find with a working copy?

 find . -type f -exec git log --reverse --format="{} %cn" -1 {} \; 
+4
source

Using git is not possible. git does not track the owner of the file.

+1
source

To do this effectively,

 git log --raw --date-order --reverse --diff-filter=A --format=%H%x09%an \ | awk -F$'\t' ' /^[^:]/ {thisauthor=$2} $1~/A$/ {print thisauthor "\t" $2} ' 

maybe |sort -t$'\t' -k1,1 or something that will make it a little prettier

0
source

All Articles