简体   繁体   中英

How to track all file changes in Git for auditing purposes

We have several developers pushing code to our master repository. For auditing purposes, I have to log all file changes to a CSV file for weekly/monthly review. I know you can go through the file change history, but this file needs to be emailed out to the team.

Does anyone know how I can do this.

We are using Azure DevOps if this matters.

The expected output should be a line-by-line list of changes with the before and after, eg:

string hello = "Hello"
string hello = "hello world"

First line is before, second line is after commit.

One way to achieve this is by tagging the repo weekly/monthly and taking the diff between the tags. see this documentation to know more about tagging. Andthis one to know about diff

For example, if you want weekly diff. tag weekly by using the command

git tag <tagname> ( git tag 04-12-2019 )

And to see the diff between two tags (say between 04-12-2019 and 11-12-2019 ) use the command

git diff 04-12-2019 11-12-2019

You can also use git log to see the log between tags eg : git log 04-12-2019 11-12-2019

To take the changes in a particular file, use

git diff 04-12-2019 11-12-2019 -- some/file/name

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM