Create a listing of changed files/directories/etc. using git between two tags
Asked Answered
D

2

6

I need to generate a changelog of sorts between two Tags within a project controlled using git, specifically the android source code. This list should include any files/directories/etc which have been edited, moved, renamed, deleted, created.

Any help would be great. And if you have a way to do this over the entire android source at once... even better.

Directoire answered 30/3, 2010 at 20:34 Comment(5)
to clarify: I do not care What changes were made within files only that they did change. i do however need to know what changed were made to directories and sym links.Directoire
Would #1039089 helps?Crutchfield
Eh? You need files but you don't need files? Your question is not very clear...Darindaring
basically I have been tasked with moving a project controlled by git into a ClearCase VCS. so therefore I do not need to know the specifics of the changes within a file, only that there has been some change to the file. the delta will be calculated by clearcase during the import.Directoire
for the import, I suppose a clearfsimport will be required. I recommend a dynamic view. See https://mcmap.net/q/880442/-sync-git-and-clearcase/… for more.Crutchfield
E
7

If you need to find which files differ:

git diff --name-only <tag1> <tag2>

If you need to find all changed files:

git log --name-only --pretty=format: <tag1>..<tag2> |
    grep -v '^$' | sort | uniq

The --pretty=format: is to supress printing information about commits, and print only the diff part. Note that in the case of git log the order of <tag1> and <tag2> matters.

Enthetic answered 30/3, 2010 at 21:6 Comment(4)
That definitely helped and I think it solves my problem for the most part. A couple of follow of questions. 1) is there a way to limit this to show only one type of element (i.e. only directories) or at the very least label the element type. 2) you mention that the tag order matters, can you point me to a doc which explains how the ordering makes a difference so I can determine my correct order. ( I will continue to research this all on my own as well and post back if I find what I am looking for independently)Directoire
edit the above example to read (i.e. only symlinks) as having read the below comment I see I will need a different command to find changed directoriesDirectoire
@dan: Re 2.) in the case of "git log <tag1>..<tag2>" it shows history from later tag2 to tag1, i.e. tag1 should be earlier than tag2. Well, you can always use symmetric <tag1>...<tag2> which shows changes from common ancestor...Whicker
Thank you, I was just able to experiment with that myself and get a feel for the difference. Especially if a file has been added/deleted the ordering will change which classification it is.Directoire
C
2

As I mention in the comments, "How do I find common files changed between git branches?" is the main solution here:

git log [--pretty=<format>] --name-only tag1..tag2

or

git diff --name-only tag1 tag2

(Also mentioned in Gitology recipe)

BUT: as mentioned in "How to get a list of directories deleted in my git repository?", Git only tracks content of files, not directories themselves.

To include informations about directories, you need to start playing with git diff-tree.

any directory that has been created or removed will have 040000 in the second or first column and 000000 in the first or second column respectively. This are the tree entry 'modes' for the left and right entries.

Something like (according to Charles Bailey):

git diff-tree -t origin/master master | grep 040000 | grep -v -E '^:040000 040000'
Crutchfield answered 30/3, 2010 at 20:58 Comment(1)
thank you for the reply and link to further information I will look over them and see if they work for my unique situation.Directoire

© 2022 - 2024 — McMap. All rights reserved.